v1.5.3: filter vereist titel-match of totaalscore >= 3
Regel C: doorlaten bij (titel-match >= 1) of (totaalscore >= 3). Een treffer in de titel is een sterke OV-intentie (score 2 volstaat); treffers alleen in de samenvatting moeten dubbel bevestigd worden. Weert bv. woningbrand-berichten die via 'bussen rijden om'/'busverkeer' in de lead binnenkwamen, zonder de 112/trein/staking-berichten te raken. Gevalideerd op 30d kamerhistorie: 96 doorlaat -> 7 geblokkeerd (allemaal ruis).
This commit is contained in:
parent
aa4f7144be
commit
cb6d00e707
2 changed files with 33 additions and 18 deletions
|
|
@ -159,10 +159,9 @@ class RSSBot(Plugin):
|
|||
self.log.exception("Fatal error while polling feeds")
|
||||
|
||||
@staticmethod
|
||||
def _filter_score(title: str, summary: str, match_filter: str) -> int:
|
||||
"""Score = 2× hits in titel + 1× hits in summary. Aaneengesloten matches
|
||||
(bv 'NS-trein', 'openbaar vervoer') tellen als 1 cluster."""
|
||||
def count(text: str) -> int:
|
||||
def _matches_in(text: str, match_filter: str) -> int:
|
||||
"""Aantal aaneengesloten match-clusters in text (0 als geen match).
|
||||
Aaneengesloten matches (bv 'NS-trein', 'openbaar vervoer') tellen als 1."""
|
||||
spans = sorted((m.start(), m.end()) for m in re.finditer(match_filter, text))
|
||||
if not spans:
|
||||
return 0
|
||||
|
|
@ -174,7 +173,23 @@ class RSSBot(Plugin):
|
|||
clusters += 1
|
||||
prev_end = e
|
||||
return clusters
|
||||
return 2 * count(title) + count(summary)
|
||||
|
||||
@staticmethod
|
||||
def _filter_score(title: str, summary: str, match_filter: str) -> int:
|
||||
"""Score = 2× hits in titel + 1× hits in summary."""
|
||||
return 2 * RSSBot._matches_in(title, match_filter) + RSSBot._matches_in(summary, match_filter)
|
||||
|
||||
@staticmethod
|
||||
def _filter_passes(title: str, summary: str, match_filter: str) -> bool:
|
||||
"""Regel C: doorlaten bij (titel-match >= 1) of (totaalscore >= 3).
|
||||
|
||||
Een OV-trefwoord in de titel is een sterke intentieverklaring (score 2
|
||||
volstaat). Treffers alleen in de samenvatting moeten dubbel bevestigd
|
||||
worden (>= 3): zo houdt 'bussen rijden om' in de lead van een
|
||||
woningbrand-bericht het artikel niet meer binnen."""
|
||||
if RSSBot._matches_in(title, match_filter) >= 1:
|
||||
return True
|
||||
return RSSBot._filter_score(title, summary, match_filter) >= 3
|
||||
|
||||
async def _send(
|
||||
self, feed: Feed, entry: Entry, sub: Subscription, *, check_filter: bool = True
|
||||
|
|
@ -183,7 +198,7 @@ class RSSBot(Plugin):
|
|||
match_filter = self.config["match_filter"]
|
||||
if match_filter:
|
||||
summary = html.unescape(re.sub(r"<[^>]+>", "", entry.summary))
|
||||
if self._filter_score(entry.title, summary, match_filter) < 2:
|
||||
if not self._filter_passes(entry.title, summary, match_filter):
|
||||
return None
|
||||
|
||||
message = sub.notification_template.safe_substitute(
|
||||
|
|
@ -217,7 +232,7 @@ class RSSBot(Plugin):
|
|||
match_filter = self.config["match_filter"]
|
||||
if match_filter:
|
||||
summary = html.unescape(re.sub(r"<[^>]+>", "", entry.summary))
|
||||
if self._filter_score(entry.title, summary, match_filter) < 2:
|
||||
if not self._filter_passes(entry.title, summary, match_filter):
|
||||
return 0, 1, 0
|
||||
spam_sleep = self.config["spam_sleep"]
|
||||
if spam_sleep >= 0:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
id: nl.eddydevink.rss
|
||||
version: 1.5.2
|
||||
version: 1.5.3
|
||||
modules:
|
||||
- buzzrss
|
||||
main_class: RSSBot
|
||||
|
|
|
|||
Loading…
Reference in a new issue