feat(tg): реальные абузы из Telegram без сессии — адаптер tg_web переписан (служебное/пустыши отсекаются, заголовок из тела, порог 12/8 для leak-каналов), 19 живых каналов из 87 проверенных, сигнал абуза в score (+до 1.8), tools/tg_discover.py, tools/fixtg.py, tools/purge_tg_junk.py, tools/rescore.py; реестр 869, база 7295 (ab_ 3135, tg_ 374); тесты 19
This commit is contained in:
44
tools/rescore.py
Normal file
44
tools/rescore.py
Normal file
@@ -0,0 +1,44 @@
|
||||
"""Пересчёт score всех записей текущей формулой rank.py (после правок веса).
|
||||
|
||||
python tools/rescore.py # показать топ-15 без записи
|
||||
python tools/rescore.py --apply # обновить items.score
|
||||
"""
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
|
||||
from omni import config, rank, store # noqa: E402
|
||||
|
||||
|
||||
class _It:
|
||||
__slots__ = ("provider", "kind", "title", "text", "published", "price", "score")
|
||||
|
||||
def __init__(self, provider, kind, title, text, published, price):
|
||||
self.provider, self.kind = provider, kind
|
||||
self.title, self.text = title or "", text or ""
|
||||
self.published, self.price, self.score = published or "", price, 0.0
|
||||
|
||||
|
||||
def main():
|
||||
apply = "--apply" in sys.argv
|
||||
c = store.conn()
|
||||
rows = c.execute("SELECT id, provider, kind, title, text, published, price, score FROM items").fetchall()
|
||||
upd, top = [], []
|
||||
for iid, prov, kind, title, text, pub, price, old in rows:
|
||||
it = rank.score(_It(prov, kind, title, text, pub, price))
|
||||
upd.append((it.score, iid))
|
||||
top.append((it.score, old, prov, title or ""))
|
||||
top.sort(reverse=True)
|
||||
print(f"записей {len(rows)}; топ по новой формуле:")
|
||||
for sc, old, prov, title in top[:15]:
|
||||
print(f" {sc:6.2f} (было {old:5.2f}) {prov[:10]:10} {title[:72]}")
|
||||
if apply:
|
||||
c.executemany("UPDATE items SET score=? WHERE id=?", upd)
|
||||
c.commit()
|
||||
print("обновлено", len(upd))
|
||||
c.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user