A single DiffQG annotation, either gold or model-generated.
| 21 | |
| 22 | @dataclasses.dataclass |
| 23 | class Annotation: |
| 24 | """A single DiffQG annotation, either gold or model-generated.""" |
| 25 | |
| 26 | base_text: str |
| 27 | target_text: str |
| 28 | answer_span: str |
| 29 | question: Optional[str] |
| 30 | is_edited: Optional[bool] = None |
| 31 | |
| 32 | def __init__(self, json_dic: Dict[str, Any]) -> None: |
| 33 | self.base_text = json_dic["base"] |
| 34 | self.target_text = json_dic["target"] |
| 35 | self.question = json_dic["q"] if json_dic["q"] else None |
| 36 | self.answer_span = json_dic["a"] |
| 37 | self.is_edited = json_dic["is_edited"] if "is_edited" in json_dic else None |
| 38 | |
| 39 | def key_annotation(self) -> str: |
| 40 | return f"{self.base_text}::{self.target_text}::{self.answer_span}" |
| 41 | |
| 42 | |
| 43 | @dataclasses.dataclass |
no outgoing calls
no test coverage detected
searching dependent graphs…