def _apply_cached_annotations()

in src/alpaca_eval/annotators/base.py [0:0]


    def _apply_cached_annotations(self, df_to_annotate: pd.DataFrame) -> pd.DataFrame:
        """annotate examples with cached annotations"""

        if self.is_store_missing_annotations:
            df_annotations = self.df_annotations
        else:
            # temorarily remove missing annotations from self.df_annotations
            df_annotations = self.df_annotations.query(f"{self.annotation_key} != {self.TMP_MISSING_ANNOTATION}")

        kwargs = {}
        if self.is_reapply_parsing:
            # if you are reapplying parsing then remove the annotation key from the cached annotations
            kwargs = dict(annotation_keys=[])

        df_to_annotate = self._merge_annotations(df_to_annotate, df_annotations, **kwargs)
        return df_to_annotate