Returns the base form of the given inflected verb, using a rule-based approach. This is problematic if a verb ending in -e is given in the past tense or gerund.
(self, verb)
| 643 | }) |
| 644 | |
| 645 | def find_lemma(self, verb): |
| 646 | """ Returns the base form of the given inflected verb, using a rule-based approach. |
| 647 | This is problematic if a verb ending in -e is given in the past tense or gerund. |
| 648 | """ |
| 649 | v = verb.lower() |
| 650 | b = False |
| 651 | if v in ("'m", "'re", "'s", "n't"): |
| 652 | return "be" |
| 653 | if v in ("'d", "'ll"): |
| 654 | return "will" |
| 655 | if v in ("'ve"): |
| 656 | return "have" |
| 657 | if v.endswith("s"): |
| 658 | if v.endswith("ies") and len(v) > 3 and v[-4] not in VOWELS: |
| 659 | return v[:-3]+"y" # complies => comply |
| 660 | if v.endswith(("sses", "shes", "ches", "xes")): |
| 661 | return v[:-2] # kisses => kiss |
| 662 | return v[:-1] |
| 663 | if v.endswith("ied") and re_vowel.search(v[:-3]) is not None: |
| 664 | return v[:-3]+"y" # envied => envy |
| 665 | if v.endswith("ing") and re_vowel.search(v[:-3]) is not None: |
| 666 | v = v[:-3]; b=True; # chopping => chopp |
| 667 | if v.endswith("ed") and re_vowel.search(v[:-2]) is not None: |
| 668 | v = v[:-2]; b=True; # danced => danc |
| 669 | if b: |
| 670 | # Doubled consonant after short vowel: chopp => chop. |
| 671 | if len(v) > 3 and v[-1] == v[-2] and v[-3] in VOWELS and v[-4] not in VOWELS and not v.endswith("ss"): |
| 672 | return v[:-1] |
| 673 | if v.endswith(("ick", "ack")): |
| 674 | return v[:-1] # panick => panic |
| 675 | # Guess common cases where the base form ends in -e: |
| 676 | if v.endswith(("v", "z", "c", "i")): |
| 677 | return v+"e" # danc => dance |
| 678 | if v.endswith("g") and v.endswith(("dg", "lg", "ng", "rg")): |
| 679 | return v+"e" # indulg => indulge |
| 680 | if v.endswith(("b", "d", "g", "k", "l", "m", "r", "s", "t")) \ |
| 681 | and len(v) > 2 and v[-2] in VOWELS and not v[-3] in VOWELS \ |
| 682 | and not v.endswith("er"): |
| 683 | return v+"e" # generat => generate |
| 684 | if v.endswith("n") and v.endswith(("an", "in")) and not v.endswith(("ain", "oin", "oan")): |
| 685 | return v+"e" # imagin => imagine |
| 686 | if v.endswith("l") and len(v) > 1 and v[-2] not in VOWELS: |
| 687 | return v+"e" # squabbl => squabble |
| 688 | if v.endswith("f") and len(v) > 2 and v[-2] in VOWELS and v[-3] not in VOWELS: |
| 689 | return v+"e" # chaf => chafed |
| 690 | if v.endswith("e"): |
| 691 | return v+"e" # decre => decree |
| 692 | if v.endswith(("th", "ang", "un", "cr", "vr", "rs", "ps", "tr")): |
| 693 | return v+"e" |
| 694 | return v |
| 695 | |
| 696 | def find_lexeme(self, verb): |
| 697 | """ For a regular verb (base form), returns the forms using a rule-based approach. |