feat(summarizer): collapse syndicated wire copies before selection
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.
This commit is contained in:
parent
fa745ee3f7
commit
d40244900e
6 changed files with 757 additions and 11 deletions
10
.env.example
10
.env.example
|
|
@ -107,6 +107,16 @@ SUMMARY_MIN_SCORE=60
|
|||
SUMMARY_TOP_N=12
|
||||
SUMMARY_FALLBACK_TOP=3
|
||||
SUMMARY_FALLBACK_MIN_SCORE=40
|
||||
# Syndication dedupe: the same wire story arrives from many station domains
|
||||
# (kcci.com, wtae.com, …) with an identical headline. Copies are collapsed
|
||||
# before the threshold/cap, so SUMMARY_TOP_N buys distinct stories: normalised
|
||||
# titles (lowercase, trailing " - KCCI"/" | CNN"/" — AP" source suffix dropped)
|
||||
# count as one story when they are equal or >= SUMMARY_DEDUPE_SIMILARITY alike.
|
||||
# The highest-scoring copy represents the story; the rest are still written to
|
||||
# article_scores with selected=false and duplicate_of = the surviving article id.
|
||||
# Set SUMMARY_DEDUPE=0 to skip dedupe entirely (old behaviour).
|
||||
SUMMARY_DEDUPE=1
|
||||
SUMMARY_DEDUPE_SIMILARITY=0.85
|
||||
SUMMARY_WINDOW_MINUTES=15
|
||||
# Futures/markets coupling from the upstream pipeline is OFF by default
|
||||
# (irrelevant to OSINT). Set INCLUDE_FUTURES=1 + install yfinance to enable.
|
||||
|
|
|
|||
Loading…
Reference in a new issue