MCPcopy Create free account
hub / github.com/google-research/language / __init__

Method __init__

language/diffqg/annotation.py:54–83  ·  view source on GitHub ↗
(self, gold_anno: Annotation, pred_anno: Annotation)

Source from the content-addressed store, hash-verified

52 pred_question: Optional[str]
53
54 def __init__(self, gold_anno: Annotation, pred_anno: Annotation) -> None:
55 if gold_anno.answer_span != pred_anno.answer_span:
56 raise ValueError(
57 "Invalid PairedAnnotation, mismatched answers: "
58 f"'{gold_anno.answer_span}' vs. "
59 f"'{pred_anno.answer_span}'."
60 )
61 if gold_anno.base_text != pred_anno.base_text:
62 raise ValueError(
63 "Invalid PairedAnnotation, mismatched base texts: "
64 f"'{gold_anno.base_text}' vs. "
65 f"'{pred_anno.base_text}'."
66 )
67 if gold_anno.target_text != pred_anno.target_text:
68 raise ValueError(
69 "Invalid PairedAnnotation, mismatched target texts: "
70 f"'{gold_anno.target_text}' vs. "
71 f"'{pred_anno.target_text}'."
72 )
73 if pred_anno.is_edited is not None:
74 raise ValueError(
75 "Possible mismatch of gold/pred annotations in making a "
76 "pair, pred_anno has no valid value for 'is_edited'."
77 )
78 self.answer_span = gold_anno.answer_span
79 self.base_text = gold_anno.base_text
80 self.target_text = gold_anno.target_text
81 self.gold_question = gold_anno.question
82 self.pred_question = pred_anno.question
83 self.is_edited = gold_anno.is_edited
84
85 def __str__(self):
86 return json.dumps(dataclasses.asdict(self))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected