From 5ea51017fbc90d3ab5e83482312b55872b2b6f50 Mon Sep 17 00:00:00 2001 From: Parshkov Date: Mon, 7 Sep 2026 02:08:27 -0700 Subject: [PATCH] A connective is not a thing, and a restatement is not a claim MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same complaint, same person, same card, one round later. After «что» stopped becoming a node, «поэтому» started heading one: the card read «поэтому система --prevents--> вмешательство». A discourse connective joins clauses and is never the head of the thing being reasoned about. English has the identical hole -- therefore, hence and thus are absent from LEADING_DROP too -- but its gold never lands on it, so only the Cyrillic side is filled and the English figures stay identical. The same card also showed «Постоянная помощь --prevents--> Постоянная помощь мешает ребёнку научиться балансировать». Unification by stem containment can relate a thing to a sentence containing it, and nothing is claimed by that. Such a relation is now abstained with a reason. That guard is not Cyrillic-scoped -- it applies to both languages -- and the extraction gate is unchanged by it, so English had never produced one. Measured on the substantive half of the idea that started this: four readable relations where there were «что --causes--> ребёнок» and «поэтому система --prevents--> вмешательство». Co-Authored-By: Claude Opus 5 --- src/extraction/cue.py | 26 ++++++++++++++++- tests/test_russian_prose_extraction.py | 40 ++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/extraction/cue.py b/src/extraction/cue.py index 992c3b4..65bc48f 100644 --- a/src/extraction/cue.py +++ b/src/extraction/cue.py @@ -182,7 +182,15 @@ "не ни нет также тоже часто обычно ещё еще уже просто даже только очень довольно слишком крайне " "как из в во на при для с со от до к ко по о об обо про за над под между через без " "быть был была было были есть буду будет будут стал стала стало стали " - "может могут мочь можно нужно надо следует стоит".split() + "может могут мочь можно нужно надо следует стоит " + # Discourse connectives. These join clauses; they are never the head of the + # thing being reasoned about, and «поэтому система уменьшает вмешательство» + # produced a node called «поэтому система». English has the same hole + # (`therefore`, `hence` and `thus` are absent from this list too) but its + # gold never lands on it, so only the Cyrillic side is filled -- which is + # what keeps the English figures identical. + "поэтому следовательно иначе зато однако впрочем причём причем притом " + "кстати наконец ведь вот ну итак значит".split() ) TRAILING_DROP = frozenset( "too again also anyway though however as well over time at all in turn itself themselves him her them it " @@ -628,6 +636,22 @@ def add_node(span: dict[str, object]) -> str | None: abstentions.append(f"dropped node {nd['label']!r} below threshold") kept_ids = {nid for nid, nd in nodes.items() if float(nd["extract_conf"]) >= self.drop_threshold} relations = [r for r in relations if r["source"] in kept_ids and r["target"] in kept_ids] + # A relation whose one end says everything the other says and more is + # not a claim about two things -- it is one thing related to a sentence + # containing it. Unification by stem containment can produce these, and + # what a person reads is «Постоянная помощь --prevents--> Постоянная + # помощь мешает ребёнку научиться балансировать». + def _degenerate(rel: Mapping[str, Any]) -> bool: + src, dst = nodes.get(rel["source"]), nodes.get(rel["target"]) + if src is None or dst is None: + return False + a = set(_stems(str(src["label"]))) + b = set(_stems(str(dst["label"]))) + return bool(a) and bool(b) and (a < b or b < a) + for rel in [r for r in relations if _degenerate(r)]: + abstentions.append( + f"one end of {rel['type']} restates the other; nothing is claimed") + relations = [r for r in relations if not _degenerate(r)] node_list = [nd for nid, nd in nodes.items() if nid in kept_ids] # node ids are derived from spans + role; recompute now that roles are final rename: dict[str, str] = {} diff --git a/tests/test_russian_prose_extraction.py b/tests/test_russian_prose_extraction.py index f215ca2..4e1e8ad 100644 --- a/tests/test_russian_prose_extraction.py +++ b/tests/test_russian_prose_extraction.py @@ -119,6 +119,46 @@ def test_a_real_causal_claim_in_the_same_document_still_reads(self): self.assertEqual(got[0][1], "causes") +class ConnectivesAreNotThingsTests(unittest.TestCase): + """Second round of the same complaint, from the same person, on the same card. + + After «что» stopped becoming a node, «поэтому» started heading one: + «поэтому система --prevents--> вмешательство». A discourse connective joins + clauses; it is never the head of the thing being reasoned about. + + English has the same hole — `therefore`, `hence` and `thus` are absent from + `LEADING_DROP` too — but its gold never lands on it, so only the Cyrillic + side is filled and the English figures stay identical. + """ + + def test_a_connective_does_not_head_a_label(self): + text = ("Постоянная помощь мешает ребёнку научиться балансировать, " + "поэтому система постепенно уменьшает вмешательство.") + labels = [n["label"] for n in graph_of(text)["nodes"]] + for label in labels: + self.assertFalse(label.lower().startswith(("поэтому", "следовательно", "иначе", "однако")), + f"a connective headed a node label: {label!r}") + + def test_a_relation_may_not_restate_one_end_in_the_other(self): + """Unification by stem containment could relate a thing to a sentence + containing it, which a person read as «Постоянная помощь --prevents--> + Постоянная помощь мешает ребёнку научиться балансировать». Nothing is + claimed by that, so it is abstained rather than shown. + + This one is not Cyrillic-scoped — it applies to both languages — and + the extraction gate is unchanged by it, so English never produced one. + """ + text = ("Постоянная помощь мешает ребёнку научиться балансировать, " + "поэтому система постепенно уменьшает вмешательство.") + d = graph_of(text) + by = {n["id"]: n["label"] for n in d["nodes"]} + from src.semantics import stems + for r in d["relations"]: + a, b = set(stems(by[r["source"]])), set(stems(by[r["target"]])) + self.assertFalse(a < b or b < a, + f"{by[r['source']]!r} --{r['type']}--> {by[r['target']]!r}") + + class CyrillicSegmentationTests(unittest.TestCase): def test_sentences_split_on_a_cyrillic_capital(self): from src.extraction.cue import sentences