quickstart: the app's schon/schön rule (plain text matching); card wording. Model and tags unchanged.
Browse files- README.md +1 -1
- quickstart.py +22 -0
README.md
CHANGED
|
@@ -201,7 +201,7 @@ Two inputs, both whole numbers (int64), shape `[1, 8]`: one sentence of 8 tokens
|
|
| 201 |
- **Guards** (`gector-guards.json`, in this repository): per-language rules that hold back edits we measured as wrong in a known shape. The scores under *How it was measured* are with the guards.
|
| 202 |
- **Spelling, checked separately** by the operating system's spell checker; the guards use it so a grammar edit is not made on a word that is misspelled.
|
| 203 |
- **A card for each change** that names the error ("Subject–verb agreement") and, on request, explains it.
|
| 204 |
-
- **A German rule for `schon` → `schön`** at the end of a clause after a form of `sein` (or `werden`, `bleiben`, `wirken`) and a word like `trotzdem`, `dennoch`, `wirklich` or `sehr`: `Die Blumen sind trotzdem schon.` → `schön`. Telling this `schon` from the correct one (`Das glaube ich schon.`, `Er ist trotzdem schon gegangen.`) needs the sentence's meaning, and two training runs (2026-11-09, 2026-11-12) could not learn it without new false alarms, so the app adds the fix itself and changes nothing else. With it, the gold set (now 190 errors) is 186 fixed; the 4 left are `hätte` / `mochte`, held back on purpose. `quickstart.py` and the in-browser demo
|
| 205 |
|
| 206 |
## Licence and attribution
|
| 207 |
|
|
|
|
| 201 |
- **Guards** (`gector-guards.json`, in this repository): per-language rules that hold back edits we measured as wrong in a known shape. The scores under *How it was measured* are with the guards.
|
| 202 |
- **Spelling, checked separately** by the operating system's spell checker; the guards use it so a grammar edit is not made on a word that is misspelled.
|
| 203 |
- **A card for each change** that names the error ("Subject–verb agreement") and, on request, explains it.
|
| 204 |
+
- **A German rule for `schon` → `schön`** at the end of a clause after a form of `sein` (or `werden`, `bleiben`, `wirken`) and a word like `trotzdem`, `dennoch`, `wirklich` or `sehr`: `Die Blumen sind trotzdem schon.` → `schön`. Telling this `schon` from the correct one (`Das glaube ich schon.`, `Er ist trotzdem schon gegangen.`) needs the sentence's meaning, and two training runs (2026-11-09, 2026-11-12) could not learn it without new false alarms, so the app adds the fix itself and changes nothing else. With it, the gold set (now 190 errors) is 186 fixed; the 4 left are `hätte` / `mochte`, held back on purpose. `quickstart.py` and the in-browser demo include the same rule (it is plain text matching, no model).
|
| 205 |
|
| 206 |
## Licence and attribution
|
| 207 |
|
quickstart.py
CHANGED
|
@@ -133,6 +133,7 @@ class Gector:
|
|
| 133 |
break
|
| 134 |
words = new_words
|
| 135 |
found = self.suggestions(plain, words) # same length as core, so positions match the real text
|
|
|
|
| 136 |
corrected = core
|
| 137 |
for f in reversed(found): # apply right to left, so positions stay valid
|
| 138 |
f["original"] = core[f["start"]: f["start"] + f["length"]]
|
|
@@ -220,6 +221,27 @@ def rejoin(tokens):
|
|
| 220 |
return out
|
| 221 |
|
| 222 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
def join(text):
|
| 224 |
"""Words back to normal text: no space before closing punctuation or after an opening mark."""
|
| 225 |
text = re.sub(f" ([{re.escape(CLOSING)}])", r"\1", " ".join(text.split()))
|
|
|
|
| 133 |
break
|
| 134 |
words = new_words
|
| 135 |
found = self.suggestions(plain, words) # same length as core, so positions match the real text
|
| 136 |
+
found = sorted(found + language_rules(core, found), key=lambda f: f["start"])
|
| 137 |
corrected = core
|
| 138 |
for f in reversed(found): # apply right to left, so positions stay valid
|
| 139 |
f["original"] = core[f["start"]: f["start"] + f["length"]]
|
|
|
|
| 221 |
return out
|
| 222 |
|
| 223 |
|
| 224 |
+
# --- a rule the app adds for a shape the model cannot learn without false alarms (model card, "What Proofbird adds") ---
|
| 225 |
+
SCHOEN = re.compile(
|
| 226 |
+
r"\b(?:ist|sind|war|waren|wäre|wären|bin|bist|seid|sei|seien|wird|werden|wurde|wurden|bleibt|bleiben|blieb|blieben|"
|
| 227 |
+
r"scheint|scheinen|schien|schienen|wirkt|wirken|wirkte|wirkten)\s+"
|
| 228 |
+
r"(?:(?:einfach|auch|doch|ja|eigentlich|halt)\s+)?"
|
| 229 |
+
r"(?:trotzdem|dennoch|wirklich|sehr|echt|total|ziemlich|besonders|unglaublich|wahnsinnig|richtig|wunderbar)\s+"
|
| 230 |
+
r"(schon)(?=\s*(?:[.!?,;:)»«\"“”]|$))", re.IGNORECASE)
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
def language_rules(text, found):
|
| 234 |
+
"""German "schon" -> "schön" at the end of a clause after a form of sein/werden/bleiben and a word like trotzdem, sehr
|
| 235 |
+
or wirklich ("Die Blumen sind trotzdem schon."). Telling it from the correct "schon" needs the sentence's meaning, so
|
| 236 |
+
the model leaves it; this rule takes only the clear shape. Skipped where the model already changed the word."""
|
| 237 |
+
out = []
|
| 238 |
+
for m in SCHOEN.finditer(text):
|
| 239 |
+
start = m.start(1)
|
| 240 |
+
if m.group(1) == "schon" and not any(f["start"] < start + 5 and start < f["start"] + max(1, f["length"]) for f in found):
|
| 241 |
+
out.append({"start": start, "length": 5, "original": "schon", "replacement": "schön", "rule": "schon/schön"})
|
| 242 |
+
return out
|
| 243 |
+
|
| 244 |
+
|
| 245 |
def join(text):
|
| 246 |
"""Words back to normal text: no space before closing punctuation or after an opening mark."""
|
| 247 |
text = re.sub(f" ([{re.escape(CLOSING)}])", r"\1", " ".join(text.split()))
|