Update llm assisted annotation

This commit is contained in:
Xin Wang
2026-09-14 23:04:21 +08:00
parent 068b7ab9e6
commit 06b5e6c385
12 changed files with 1348 additions and 238 deletions

View File

@@ -11,6 +11,7 @@ from review_floor_events import (
expand_candidate_paths,
load_candidates,
parse_byte_range,
stream_file_range,
)
@@ -61,6 +62,16 @@ class FloorEventReviewTests(unittest.TestCase):
"ai_verdict": "POSITIVE",
"ai_event_type": "EOT_RESPONSE",
"ai_subtype": None,
"speaker_timeline": [
{
"uid": "Session_4/00-00-000/0001",
"participant_id": 2,
"participant_role": "wearer",
"start_seconds": 1.2,
"end_seconds": 2.0,
"transcription": "Yes.",
}
],
}
)
+ "\n",
@@ -91,6 +102,8 @@ class FloorEventReviewTests(unittest.TestCase):
self.assertEqual(detail["event_local_seconds"], 1.2)
self.assertEqual(len(detail["transcript"]), 2)
self.assertTrue(detail["transcript"][1]["is_anchor"])
self.assertEqual(detail["transcript"][1]["participant_role"], "wearer")
self.assertEqual(detail["transcript"][1]["uid"], "Session_4/00-00-000/0001")
self.assertEqual(len(repository.session_timelines["Session_4"]), 2)
def test_review_store_writes_resumable_jsonl_and_csv(self) -> None:
@@ -108,7 +121,6 @@ class FloorEventReviewTests(unittest.TestCase):
"exclude_reason": None,
"boundary_correction_seconds": None,
"confidence": "high",
"reviewer": "r1",
"notes": "clear acknowledgement",
}
store.save(candidates[0].candidate_id, review)
@@ -120,6 +132,7 @@ class FloorEventReviewTests(unittest.TestCase):
"EOT_RESPONSE",
)
self.assertFalse(resumed.reviews[candidates[0].candidate_id]["review"]["relabeled"])
self.assertEqual(resumed.reviews[candidates[0].candidate_id]["review"]["reviewer"], "")
def test_directory_expansion_excludes_output(self) -> None:
with tempfile.TemporaryDirectory() as temporary:
@@ -133,6 +146,33 @@ class FloorEventReviewTests(unittest.TestCase):
[candidate.resolve()],
)
def test_primary_queue_skips_legacy_nonoverlap_wearer_offset(self) -> None:
with tempfile.TemporaryDirectory() as temporary:
path = Path(temporary) / "legacy.jsonl"
rows = [
{
"uid": "Session_4/wearer_offset/00000285",
"candidate_source": "WEARER_OFFSET",
"task": "int_yield",
"temporal_evidence": {
"active_other_ids_before_offset": [],
"active_other_ids_after_offset": [],
},
},
{
"uid": "Session_4/wearer_onset/00000338",
"candidate_source": "WEARER_ONSET",
"task": "eot_response",
},
]
path.write_text(
"".join(json.dumps(row) + "\n" for row in rows), encoding="utf-8"
)
primary = load_candidates([path])
all_rows = load_candidates([path], include_offset_controls=True)
self.assertEqual([row.uid for row in primary], [rows[1]["uid"]])
self.assertEqual(len(all_rows), 2)
def test_relabel_preserves_ai_and_records_human_decision(self) -> None:
with tempfile.TemporaryDirectory() as temporary:
root = Path(temporary)
@@ -161,6 +201,16 @@ class FloorEventReviewTests(unittest.TestCase):
with self.assertRaises(ValueError):
parse_byte_range("bytes=20-30", 10)
def test_cancelled_media_stream_is_not_an_error(self) -> None:
class Reader:
def read(self, _: int) -> bytes:
return b"video"
def disconnected(_: bytes) -> None:
raise BrokenPipeError(32, "Broken pipe")
self.assertFalse(stream_file_range(Reader(), disconnected, 5))
if __name__ == "__main__":
unittest.main()