MVP 1.0
This commit is contained in:
1 parent
be11f82f84
commit
e42f751fdc
47 files changed
+3359
-301
No files matched your search
@@ -134,12 +134,15 @@ def main() -> None:
|
||||
0,
|
||||
)
|
||||
expect(span.text == "Anna" and span.start == start, "valid span matches the local substring")
|
||||
relocated = validate_detected_entity(
|
||||
{"start": 0, "end": 4, "text": "Anna", "entity_type": "PERSON"},
|
||||
sample,
|
||||
0,
|
||||
expect(
|
||||
validate_detected_entity(
|
||||
{"start": 0, "end": 4, "text": "Anna", "entity_type": "PERSON"},
|
||||
sample,
|
||||
0,
|
||||
).start
|
||||
== start,
|
||||
"wrong offsets are grounded to the local word",
|
||||
)
|
||||
expect(relocated is not None and relocated.start == start and relocated.text == "Anna", "wrong offsets are grounded to the local word")
|
||||
expect(
|
||||
validate_detected_entity(
|
||||
{"start": -1, "end": 4, "text": "Anna", "entity_type": "PERSON"},
|
||||
@@ -149,15 +152,20 @@ def main() -> None:
|
||||
== start,
|
||||
"negative offsets still ground when the word exists",
|
||||
)
|
||||
expect(
|
||||
try:
|
||||
validate_detected_entity(
|
||||
{"start": 0, "end": 4, "text": "Nein", "entity_type": "PERSON"},
|
||||
sample,
|
||||
0,
|
||||
)
|
||||
is None,
|
||||
"a word that is not in the chunk is skipped",
|
||||
)
|
||||
missing_word = False
|
||||
except DetectError as exc:
|
||||
missing_word = exc.code == "detect_invalid_output"
|
||||
expect(
|
||||
(exc.diagnostics or {}).get("contract_violation") == "unusable_offsets",
|
||||
"a word that is not in the chunk is a contract violation",
|
||||
)
|
||||
expect(missing_word, "a word that is not in the chunk fails closed")
|
||||
expect(
|
||||
validate_detected_entity(
|
||||
{"start": "x", "end": 4, "text": "Anna", "entity_type": "PERSON"},
|
||||
|
||||
Reference in new issue
Block a user