feat(summarizer): collapse syndicated duplicate stories before selection #55
Loading…
Reference in a new issue
No description provided.
Delete branch "wt/t_b3af1cb0"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Syndicated wire copies are collapsed before the score threshold and
SUMMARY_TOP_Ncap, so the slot budget buys distinct stories instead of station copies.Follow-up to #54. Measured defect on summary id=6: 21 graded articles, 9 distinct titles, 12 selected blocks that were only two stories (Trump-Xi-Putin summit carried by 7 Hearst domains, FAA ground stop by 6).
Changes
news/summerizer/intel.py: purededupe_blocks(blocks, *, similarity=0.85, enabled=True)plusnormalize_title/title_similarity.- KCCI,| CNN,- AP), keep[a-z0-9 ], collapse whitespace;difflibratio >=SUMMARY_DEDUPE_SIMILARITY;categoryvalues, and never merges titles that disagree on a number (wire copy is verbatim);news/summerizer/summarizer.py: dedupegradedbeforeselect_graded(), one log linededupe 21 -> 9 (kept 9, duplicates 12);SUMMARY_DEDUPE=0skips it,SUMMARY_DEDUPE_SIMILARITYtunes it.persist_article_scores()still writes one row per graded article - duplicates getselected=falseandduplicate_of= survivingarticle_id.article_scores.duplicate_of INTEGER NULL:ensure_tables()DDL + alembic 013 (upgrade and downgrade verified against Postgres 16)..env.example+docs/news.md: both knobs documented in the grading paragraph and config table.Verification
cd news/summerizer && pytest tests -q: 78 -> 106 passed (+28 new intests/test_dedupe.py).min_score=60, top_n=12select 2 (scores[95, 75]).ensure_tables()+persist_article_scores()):Premise note (measured, not assumed)
I ran the heuristic over the 500 most recent live titles (24h feed mix) and inspected every merged group. Two false-merge classes appeared and both are now vetoed by the digit-free-suffix / numbers-differ rules:
... - Part 1vs... - Part 2(wiseye.org) and horoscope boilerplate variants.The horoscope class still merges at 0.85 (identical 16-word template, one sign word different) - it is noise (score 5, never selected), and
SUMMARY_DEDUPE_SIMILARITY=0.96removes it at the cost of one real variant (...across U.S....copy at 0.889). No editorially significant story merged at 0.85 in this sample: every true syndication cluster scored 0.970-1.000. Default left at 0.85 per spec; raising it is a ConfigMap-only change.Merge policy: do not merge - operator merges, rebuilds
osint-news-summarizer, pins the sha insirius/homek8s, then re-runs a forced interval.The map phase grades every article, but a single wire story arrives from many station domains with an identical headline (the measured run selected 12 blocks that were only two stories, then produced a ticker with five summit rows and one FAA row). Dedupe now runs before the threshold/cap, so SUMMARY_TOP_N buys distinct stories. - intel.py: pure `dedupe_blocks(blocks, *, similarity, enabled)` plus `normalize_title` / `title_similarity`. Titles are lowercased, punctuation flattened and a short digit-free trailing source suffix (" - KCCI", " | CNN", " — AP") dropped; blocks match on equal normalised titles or word-set Jaccard / word-sequence difflib ratio >= similarity (default 0.85). Best score wins the group (ties -> earliest), matching is against the representative only (no transitive chaining), and differing categories or differing numbers never merge. Blocks now carry their article title. - summarizer.py: dedupe graded blocks before select_graded() and log `dedupe 21 -> 9 (kept 9, duplicates 12)`; SUMMARY_DEDUPE=0 skips it, SUMMARY_DEDUPE_SIMILARITY tunes it. persist_article_scores() still writes one row per graded article, with duplicates selected=false and duplicate_of pointing at the surviving article id. - article_scores.duplicate_of INTEGER NULL in ensure_tables() and alembic 013 (upgrade/downgrade verified against Postgres 16). - docs/news.md + .env.example document both knobs. Replaying the observed summary id=6 (21 graded, 9 distinct titles) now keeps 9 and, at min_score=60/top_n=12, selects 2 — the 11 dropped copies that scored >= 60 are stored selected=false with a duplicate_of pointer.