dp-zp-agent/tools/retrieval/stopwords.py
jp170na 73e895af41 oprava mien CRZP, čistenie šumu, spoločné stop-slová, stretnutia
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 04:18:10 +01:00

44 lines
2.7 KiB
Python

"""Slovak function words: one list for every place that keeps only the content words of a question.
Topics, keywords, search terms and name mentions are read without these words (folded: lower case,
no diacritics). Each place adds its own domain words ("praca", "tema", "osoba") to FUNCTION_WORDS;
nothing here is domain specific.
The words that carry a condition are never in FUNCTION_WORDS (CONDITION_WORDS: "nie", "bez",
"okrem", "ani", "iba", "len", "ale"): conditions ("bez RASA", "ale nie s Neo4j", "iba v roku 2024")
are read from the whole question before any stop words are dropped, and a list that drops them
anyway (a topic is never "bez") names them itself. The question words ("kto", "kolko", "kedy") are
function words here: they are no topic, while the question type is read from the whole question.
"""
from __future__ import annotations
FUNCTION_WORDS = frozenset("""
a aj i alebo ci ze aby ked ak pretoze lebo tak takze teda ako akoby
v vo na o z zo s so k ku do od pre pri po za nad pod pred medzi cez u okolo podla kvoli voci
ja ty on ona ono my vy oni ony ma mi mna mne ta ti teba tebe ho mu ju jej jeho ich im nim nimi nich neho nej nu
si sa seba sebe svoj svoja svoje svojho svojej svoju svojom svojim svojich svojimi
to ten tento tato toto tieto tito tie tom tomto tej tejto tu tuto tych tychto tymi tymto tomu toho tohto
ktory ktora ktore ktori ktoreho ktorej ktoru ktorom ktorych ktorym ktorymi
aky aka ake aki akeho akej aku akom akych akym akymi
co coho comu com cim kto koho komu kom kym kolko kolkych kedy kde preco odkial
niekto nieco niecoho niecom niecim nejaky nejaka nejake nejaku nejakeho nejakej nejakom nejakych
kazdy kazda kazde kazdeho kazdej vsetko vsetci vsetky vsetkych vsetkym
je su som sme ste bol bola bolo boli byt bude budu by
mam mas mame maju mal mala mali
uz este tiez vsak vobec niekedy prave asi napr napriklad potom tam
""".split())
# Function words that are names too (folded: "Ján Naď", "Juraj Tej", "Tomáš Kazda", "Dávid Lebo", "Dana Malá",
# "Tom Levy" in the register; "máte" and "malo" are left out of FUNCTION_WORDS, being "Máté" and "Peter Malo"):
# the lists that find name mentions in a question (person_names, the CRZP rules) do not get them from here.
NAME_WORDS = frozenset("a o s k ku do ho ma to tom nad tej kazda lebo budu bolo mala".split())
NAME_STOP = FUNCTION_WORDS - NAME_WORDS
# Words that carry a condition of the question: never dropped by the shared list.
CONDITION_WORDS = frozenset("nie ne bez okrem ani iba len ale avsak nez".split())
# English function words of titles and keywords ("Machine learning for the Slovak language").
ENGLISH_FUNCTION_WORDS = frozenset("a an and based by for from in of on the to using with".split())
assert not FUNCTION_WORDS & CONDITION_WORDS and NAME_WORDS <= FUNCTION_WORDS