You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Polish stop-words ma/na/co/sa: the N/A and S.A. collisions don't reproduce — propose acronym-preservation over removal #64
Hi Toni — following up on the ma / na / co / sa question you left for "the Polish eye" in #57. I ran the same collision audit we used for Vietnamese, with the real extractor, and it points somewhere different from removing them — so an issue rather than a PR.
What the audit found (live, language="pl")
The tokenizer keeps only letter runs on lowercased text (re.findall(r"\b[a-zA-ZÀ-ỹ]+...\b") over text.lower()), which changes the picture:
word
punctuated form
bare acronym
Polish function word (noise if removed)
na
N/A does NOT collide — the / splits it into n + a, both below min-length
NA (North America) collides
na (on/at) — one of the most frequent PL words
sa
S.A. does NOT collide — the . splits it into s + a
SA collides (much rarer than S.A.)
są/sa (are) — common
co
C/O does NOT collide
CO collides
co (what) — common
ma
(no punctuated form)
MA (moving average) collides
ma (has) — very frequent PL verb
So the specific collisions that motivated na and sa (N/A, S.A.) don't actually happen — the punctuation fragments them below the min-length guard. Only the bare uppercase acronyms collide, and for all four the Polish function word is far more common in real content than the acronym. That's the inverse of the ci ↔ CI case, where the acronym was ubiquitous and the function word rare.
Conclusion: removing ma/na/co/sa from STOP_WORDS_PL would trade a lot of function-word noise for a niche acronym gain. I don't think it's worth it as a straight removal.
The better fix: preserve uppercase acronyms
The root cause is that extract_weighted_keywords lowercases up front (_CLAUSE_BOUNDARY.split(text.lower())), which conflates the acronym MA with the function word ma. A targeted fix would keep a token that was ALL-CAPS (≥2 chars) in the original text even when its lowercased form is a stop-word — so MA, CO, NA, SA (and every other acronym) survive, without letting the Polish function words through.
That needs the tokenizer to carry original case (today it's discarded at .lower()), so it's a bit more than a one-line stop-word edit — hence an issue first. Happy to send a PR if you like the direction.
(The per-word audit script is small and I can share it if useful.)
Verified against current main (after today's merges, including #65 which touched this same file): the premises still hold — _CLAUSE_BOUNDARY.split(text.lower()) at keywords.py:618, and ma/na/co/sa are all still in STOP_WORDS_PL.
The audit is the useful part here, and I want to be explicit about why: you went looking for evidence for a change you had already been invited to make, found it did not hold, and said so. N/A and S.A. fragmenting below the min-length guard is exactly the kind of detail that only shows up when someone runs the real extractor instead of reasoning about it. Straight removal is off the table.
The acronym-preservation direction is the right one — please send the PR.
Two things I would ask for, given it means carrying original case through the tokenizer:
Keep the ALL-CAPS rule tight (≥2 chars, whole token uppercase in the source). Loosening it to "any token with a capital" would let sentence-initial Ma/Na back in, which is the noise we are trying to avoid.
A test pinning both directions per word: MA survives, ma does not. The ci ↔ CI asymmetry you describe is precisely the thing a future well-meaning edit would flatten.
The audit script would be useful in the PR description if it is short — not as a committed file, just so the reasoning is recorded where the next person will look.
Thanks for turning a one-line request into an actual measurement.
Same note as on #80: this one is yours if you want it — we are not implementing it on our side, so the PR you offered will not collide with anything.
The direction is approved as stated in my previous comment; the two asks stand (keep the ALL-CAPS rule tight, and pin both directions per word in a test). keywords.py did change today via #65 (en-dash added to _CLAUSE_BOUNDARY), so rebase before you start — the line you will be touching sits right next to it.
Thanks — this one can be closed, and the credit is yours.
I came back to prepare the PR you asked for and found it already in main. src/surreal_memory/extraction/keywords.py now computes a caps ratio over the raw tokens and gates the rescue on it:
That is exactly the narrow rule you set out in this thread — whole-token upper case in the source, at least two characters — plus a ratio guard I had not thought of. The guard is the better part: a shouted note or an all-caps heading has no acronym to rescue, only words that happen to be capitalised, and it would have been quietly wrong to disable stop-word filtering for the whole document in that case. My version did not have it.
Verified on 13afdca4 (v3.4.0). Nothing further needed from my side.
One apology for the gap between the offer and this note. I had rather more queued up than survived contact with 3.4.0 — three releases on 3 August, then 3.3.1 and 3.4.0 — and a good part of what I had prepared was fixed upstream before I got it out of the door. That is entirely a compliment to the pace; it is a good problem for a library to have. I will send the few things that are still genuinely live as separate, small PRs rather than a batch.
Thanks — this one can be closed, and the credit is yours.
I came back to prepare the PR you asked for and found it already in main. src/surreal_memory/extraction/keywords.py now computes a caps ratio over the raw tokens and gates the rescue on it:
That is exactly the narrow rule you set out in this thread — whole-token upper case in the source, at least two characters — plus a ratio guard I had not thought of. The guard is the better part: a shouted note or an all-caps heading has no acronym to rescue, only words that happen to be capitalised, and it would have been quietly wrong to disable stop-word filtering for the whole document in that case. My version did not have it.
Verified on 13afdca4 (v3.4.0). Nothing further needed from my side.
One apology for the gap between the offer and this note. I had rather more queued up than survived contact with 3.4.0 — three releases on 3 August, then 3.3.1 and 3.4.0 — and a good part of what I had prepared was fixed upstream before I got it out of the door. That is entirely a compliment to the pace; it is a good problem for a library to have. I will send the few things that are still genuinely live as separate, small PRs rather than a batch.
Thanks — this one can be closed, and the credit is yours.
I came back to prepare the PR you asked for and found it already in main. src/surreal_memory/extraction/keywords.py now computes a caps ratio over the raw tokens and gates the rescue on it:
That is exactly the narrow rule you set out in this thread — whole-token upper case in the source, at least two characters — plus a ratio guard I had not thought of. The guard is the better part: a shouted note or an all-caps heading has no acronym to rescue, only words that happen to be capitalised, and it would have been quietly wrong to disable stop-word filtering for the whole document in that case. My version did not have it.
Verified on 13afdca4 (v3.4.0). Nothing further needed from my side.
One apology for the gap between the offer and this note. I had rather more queued up than survived contact with 3.4.0 — three releases on 3 August, then 3.3.1 and 3.4.0 — and a good part of what I had prepared was fixed upstream before I got it out of the door. That is entirely a compliment to the pace; it is a good problem for a library to have. I will send the few things that are still genuinely live as separate, small PRs rather than a batch.
Thanks — this one can be closed, and the credit is yours.
I came back to prepare the PR you asked for and found it already in main. src/surreal_memory/extraction/keywords.py now computes a caps ratio over the raw tokens and gates the rescue on it:
That is exactly the narrow rule you set out in this thread — whole-token upper case in the source, at least two characters — plus a ratio guard I had not thought of. The guard is the better part: a shouted note or an all-caps heading has no acronym to rescue, only words that happen to be capitalised, and it would have been quietly wrong to disable stop-word filtering for the whole document in that case. My version did not have it.
Verified on 13afdca4 (v3.4.0). Nothing further needed from my side.
One apology for the gap between the offer and this note. I had rather more queued up than survived contact with 3.4.0 — three releases on 3 August, then 3.3.1 and 3.4.0 — and a good part of what I had prepared was fixed upstream before I got it out of the door. That is entirely a compliment to the pace; it is a good problem for a library to have. I will send the few things that are still genuinely live as separate, small PRs rather than a batch.
Thanks — this one can be closed, and the credit is yours.
I came back to prepare the PR you asked for and found it already in main. src/surreal_memory/extraction/keywords.py now computes a caps ratio over the raw tokens and gates the rescue on it:
That is exactly the narrow rule you set out in this thread — whole-token upper case in the source, at least two characters — plus a ratio guard I had not thought of. The guard is the better part: a shouted note or an all-caps heading has no acronym to rescue, only words that happen to be capitalised, and it would have been quietly wrong to disable stop-word filtering for the whole document in that case. My version did not have it.
Verified on 13afdca4 (v3.4.0). Nothing further needed from my side.
One apology for the gap between the offer and this note. I had rather more queued up than survived contact with 3.4.0 — three releases on 3 August, then 3.3.1 and 3.4.0 — and a good part of what I had prepared was fixed upstream before I got it out of the door. That is entirely a compliment to the pace; it is a good problem for a library to have. I will send the few things that are still genuinely live as separate, small PRs rather than a batch.
Fixed in #157 (v3.5.0-era audit re-verified just now on main): implemented exactly as proposed here — ma/na/co/sastay in STOP_WORDS_PL, and extract_weighted_keywords (src/surreal_memory/extraction/keywords.py) now tokenizes with original casing and rescues a token whose lowercased form is a stop word only if the whole token was ALL-CAPS with len >= 2 — so MA/NA/CO/SA survive while the function words do not. A caps-ratio guard keeps all-caps text from disabling stop-word filtering wholesale. Pinned by tests/unit/test_polish_keywords.py ("ma/na/co/sa: the acronym survives, the Polish function word does not (#64)"). Thanks for the audit — it changed the fix from the wrong one to the right one.
Activity
acidkill commentedon Jul 28, 2026
Verified against current
main(after today's merges, including #65 which touched this same file): the premises still hold —_CLAUSE_BOUNDARY.split(text.lower())atkeywords.py:618, andma/na/co/saare all still inSTOP_WORDS_PL.The audit is the useful part here, and I want to be explicit about why: you went looking for evidence for a change you had already been invited to make, found it did not hold, and said so.
N/AandS.A.fragmenting below the min-length guard is exactly the kind of detail that only shows up when someone runs the real extractor instead of reasoning about it. Straight removal is off the table.The acronym-preservation direction is the right one — please send the PR.
Two things I would ask for, given it means carrying original case through the tokenizer:
Ma/Naback in, which is the noise we are trying to avoid.MAsurvives,madoes not. Theci↔CIasymmetry you describe is precisely the thing a future well-meaning edit would flatten.The audit script would be useful in the PR description if it is short — not as a committed file, just so the reasoning is recorded where the next person will look.
Thanks for turning a one-line request into an actual measurement.
acidkill commentedon Jul 28, 2026
Same note as on #80: this one is yours if you want it — we are not implementing it on our side, so the PR you offered will not collide with anything.
The direction is approved as stated in my previous comment; the two asks stand (keep the ALL-CAPS rule tight, and pin both directions per word in a test).
keywords.pydid change today via #65 (en-dash added to_CLAUSE_BOUNDARY), so rebase before you start — the line you will be touching sits right next to it.fix: address 6 open issues (#64, #150-#154) and bump to v3.3.0 (#157)
RobertSigmundsson commentedon Aug 15, 2026
Thanks — this one can be closed, and the credit is yours.
I came back to prepare the PR you asked for and found it already in
main.src/surreal_memory/extraction/keywords.pynow computes a caps ratio over the raw tokens and gates the rescue on it:That is exactly the narrow rule you set out in this thread — whole-token upper case in the source, at least two characters — plus a ratio guard I had not thought of. The guard is the better part: a shouted note or an all-caps heading has no acronym to rescue, only words that happen to be capitalised, and it would have been quietly wrong to disable stop-word filtering for the whole document in that case. My version did not have it.
Verified on
13afdca4(v3.4.0). Nothing further needed from my side.One apology for the gap between the offer and this note. I had rather more queued up than survived contact with 3.4.0 — three releases on 3 August, then 3.3.1 and 3.4.0 — and a good part of what I had prepared was fixed upstream before I got it out of the door. That is entirely a compliment to the pace; it is a good problem for a library to have. I will send the few things that are still genuinely live as separate, small PRs rather than a batch.
RobertSigmundsson commentedon Aug 15, 2026
Thanks — this one can be closed, and the credit is yours.
I came back to prepare the PR you asked for and found it already in
main.src/surreal_memory/extraction/keywords.pynow computes a caps ratio over the raw tokens and gates the rescue on it:That is exactly the narrow rule you set out in this thread — whole-token upper case in the source, at least two characters — plus a ratio guard I had not thought of. The guard is the better part: a shouted note or an all-caps heading has no acronym to rescue, only words that happen to be capitalised, and it would have been quietly wrong to disable stop-word filtering for the whole document in that case. My version did not have it.
Verified on
13afdca4(v3.4.0). Nothing further needed from my side.One apology for the gap between the offer and this note. I had rather more queued up than survived contact with 3.4.0 — three releases on 3 August, then 3.3.1 and 3.4.0 — and a good part of what I had prepared was fixed upstream before I got it out of the door. That is entirely a compliment to the pace; it is a good problem for a library to have. I will send the few things that are still genuinely live as separate, small PRs rather than a batch.
RobertSigmundsson commentedon Aug 15, 2026
Thanks — this one can be closed, and the credit is yours.
I came back to prepare the PR you asked for and found it already in
main.src/surreal_memory/extraction/keywords.pynow computes a caps ratio over the raw tokens and gates the rescue on it:That is exactly the narrow rule you set out in this thread — whole-token upper case in the source, at least two characters — plus a ratio guard I had not thought of. The guard is the better part: a shouted note or an all-caps heading has no acronym to rescue, only words that happen to be capitalised, and it would have been quietly wrong to disable stop-word filtering for the whole document in that case. My version did not have it.
Verified on
13afdca4(v3.4.0). Nothing further needed from my side.One apology for the gap between the offer and this note. I had rather more queued up than survived contact with 3.4.0 — three releases on 3 August, then 3.3.1 and 3.4.0 — and a good part of what I had prepared was fixed upstream before I got it out of the door. That is entirely a compliment to the pace; it is a good problem for a library to have. I will send the few things that are still genuinely live as separate, small PRs rather than a batch.
RobertSigmundsson commentedon Aug 15, 2026
Thanks — this one can be closed, and the credit is yours.
I came back to prepare the PR you asked for and found it already in
main.src/surreal_memory/extraction/keywords.pynow computes a caps ratio over the raw tokens and gates the rescue on it:That is exactly the narrow rule you set out in this thread — whole-token upper case in the source, at least two characters — plus a ratio guard I had not thought of. The guard is the better part: a shouted note or an all-caps heading has no acronym to rescue, only words that happen to be capitalised, and it would have been quietly wrong to disable stop-word filtering for the whole document in that case. My version did not have it.
Verified on
13afdca4(v3.4.0). Nothing further needed from my side.One apology for the gap between the offer and this note. I had rather more queued up than survived contact with 3.4.0 — three releases on 3 August, then 3.3.1 and 3.4.0 — and a good part of what I had prepared was fixed upstream before I got it out of the door. That is entirely a compliment to the pace; it is a good problem for a library to have. I will send the few things that are still genuinely live as separate, small PRs rather than a batch.
RobertSigmundsson commentedon Aug 15, 2026
Thanks — this one can be closed, and the credit is yours.
I came back to prepare the PR you asked for and found it already in
main.src/surreal_memory/extraction/keywords.pynow computes a caps ratio over the raw tokens and gates the rescue on it:That is exactly the narrow rule you set out in this thread — whole-token upper case in the source, at least two characters — plus a ratio guard I had not thought of. The guard is the better part: a shouted note or an all-caps heading has no acronym to rescue, only words that happen to be capitalised, and it would have been quietly wrong to disable stop-word filtering for the whole document in that case. My version did not have it.
Verified on
13afdca4(v3.4.0). Nothing further needed from my side.One apology for the gap between the offer and this note. I had rather more queued up than survived contact with 3.4.0 — three releases on 3 August, then 3.3.1 and 3.4.0 — and a good part of what I had prepared was fixed upstream before I got it out of the door. That is entirely a compliment to the pace; it is a good problem for a library to have. I will send the few things that are still genuinely live as separate, small PRs rather than a batch.
acidkill commentedon Aug 15, 2026
Fixed in #157 (v3.5.0-era audit re-verified just now on
main): implemented exactly as proposed here —ma/na/co/sastay inSTOP_WORDS_PL, andextract_weighted_keywords(src/surreal_memory/extraction/keywords.py) now tokenizes with original casing and rescues a token whose lowercased form is a stop word only if the whole token was ALL-CAPS with len >= 2 — soMA/NA/CO/SAsurvive while the function words do not. A caps-ratio guard keeps all-caps text from disabling stop-word filtering wholesale. Pinned bytests/unit/test_polish_keywords.py("ma/na/co/sa: the acronym survives, the Polish function word does not (#64)"). Thanks for the audit — it changed the fix from the wrong one to the right one.