| 342 | return s.replace("ss", u"ß") |
| 343 | |
| 344 | class Verbs(_Verbs): |
| 345 | |
| 346 | def __init__(self): |
| 347 | _Verbs.__init__(self, os.path.join(MODULE, "de-verbs.txt"), |
| 348 | language = "de", |
| 349 | format = [0, 1, 2, 3, 4, 5, 8, 17, 18, 19, 20, 21, 24, 52, 54, 53, 55, 56, 58, 59, 67, 68, 70, 71], |
| 350 | default = {6: 4, 22: 20, 57: 55, 60: 58, 69: 67, 72: 70} |
| 351 | ) |
| 352 | |
| 353 | def find_lemma(self, verb): |
| 354 | """ Returns the base form of the given inflected verb, using a rule-based approach. |
| 355 | """ |
| 356 | v = verb.lower() |
| 357 | # Common prefixes: be-finden and emp-finden probably inflect like finden. |
| 358 | if not (v.startswith("ge") and v.endswith("t")): # Probably gerund. |
| 359 | for prefix in prefixes: |
| 360 | if v.startswith(prefix) and v[len(prefix):] in self.inflections: |
| 361 | return prefix + self.inflections[v[len(prefix):]] |
| 362 | # Common sufixes: setze nieder => niedersetzen. |
| 363 | b, suffix = " " in v and v.split()[:2] or (v, "") |
| 364 | # Infinitive -ln: trommeln. |
| 365 | if b.endswith(("ln", "rn")): |
| 366 | return b |
| 367 | # Lemmatize regular inflections. |
| 368 | for x in ("test", "est", "end", "ten", "tet", "en", "et", "te", "st", "e", "t"): |
| 369 | if b.endswith(x): b = b[:-len(x)]; break |
| 370 | # Subjunctive: hielte => halten, schnitte => schneiden. |
| 371 | for x, y in ( |
| 372 | ("ieb", "eib"), ( "ied", "eid"), ( "ief", "auf" ), ( "ieg", "eig" ), ("iel", "alt"), |
| 373 | ("ien", "ein"), ("iess", "ass"), (u"ieß", u"aß" ), ( "iff", "eif" ), ("iss", "eiss"), |
| 374 | (u"iß", u"eiß"), ( "it", "eid"), ( "oss", "iess"), (u"öss", "iess")): |
| 375 | if b.endswith(x): b = b[:-len(x)] + y; break |
| 376 | b = b.replace("eeiss", "eiss") |
| 377 | b = b.replace("eeid", "eit") |
| 378 | # Subjunctive: wechselte => wechseln |
| 379 | if not b.endswith(("e", "l")) and not (b.endswith("er") and not b[-3] in VOWELS): |
| 380 | b = b + "e" |
| 381 | # abknallst != abknalln => abknallen |
| 382 | if b.endswith(("hl", "ll", "ul", "eil")): |
| 383 | b = b + "e" |
| 384 | # Strip ge- from (likely) gerund: |
| 385 | if b.startswith("ge") and v.endswith("t"): |
| 386 | b = b[2:] |
| 387 | # Corrections (these add about 1.5% accuracy): |
| 388 | if b.endswith(("lnde", "rnde")): |
| 389 | b = b[:-3] |
| 390 | if b.endswith(("ae", "al", u"öe", u"üe")): |
| 391 | b = b.rstrip("e") + "te" |
| 392 | if b.endswith(u"äl"): |
| 393 | b = b + "e" |
| 394 | return suffix + b + "n" |
| 395 | |
| 396 | def find_lexeme(self, verb): |
| 397 | """ For a regular verb (base form), returns the forms using a rule-based approach. |
| 398 | """ |
| 399 | v = verb.lower() |
| 400 | # Stem = infinitive minus -en, -ln, -rn. |
| 401 | b = b0 = re.sub("en$", "", re.sub("ln$", "l", re.sub("rn$", "r", v))) |
no outgoing calls
no test coverage detected
searching dependent graphs…