MCPcopy Create free account
hub / github.com/cxcscmu/Craw4LLM / DocumentAnnotation

Class DocumentAnnotation

corpus_interface.py:11–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10
11class DocumentAnnotation(dict):
12 _compare_key: str | None = None
13 _order: str = "desc"
14
15 def __init__(self, *args, **kwargs):
16 super().__init__(*args, **kwargs)
17
18 @classmethod
19 def set_compare_method(cls, key: str, order: Literal["desc", "asc"]) -> None:
20 cls._compare_key = key
21 if order not in ["desc", "asc"]:
22 raise ValueError("Order must be either 'desc' (descending) or 'asc' (ascending)")
23 cls._order = order
24
25 @classmethod
26 def get_compare_key(cls) -> str | None:
27 return cls._compare_key
28
29 def __lt__(self, other) -> bool:
30 if self._compare_key is None:
31 raise ValueError("Compare key not set")
32 if self._order == "desc":
33 return self[self._compare_key] > other[self._compare_key]
34 return self[self._compare_key] < other[self._compare_key]
35
36
37@dataclass

Callers 1

_annotate_docMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected