Python 3.x 检测动词是弱动词还是强动词

Python 3.x 检测动词是弱动词还是强动词,python-3.x,nlp,Python 3.x,Nlp,说明: 如果一个动词结尾包含d,ed,t,那么我们称之为弱动词 如果动词中出现任何元音变化,那么根据我的理解,我们将其称为强动词,并在本链接中提到我已经实现并尝试涵盖检测弱动词或强动词的所有情况 请帮助我创建一个算法,通过覆盖所有测试用例来检测弱动词 from collections import Counter def is_vowel(char): """ check for char is vowel or not """ return 'aeiou'._

说明: 如果一个动词结尾包含d,ed,t,那么我们称之为弱动词 如果动词中出现任何元音变化,那么根据我的理解,我们将其称为强动词,并在本链接中提到我已经实现并尝试涵盖检测弱动词或强动词的所有情况 请帮助我创建一个算法,通过覆盖所有测试用例来检测弱动词

from collections import Counter

def is_vowel(char):
    """
    check for char is vowel or not
    """
    return 'aeiou'.__contains__(char.lower())

def LetterCount(text):
    """
    Create the alphabet count dictionary using counter
    """
    return dict(Counter(c for c in text.lower() if c.isalpha()))


def change_vowel_detect(verb1, verb3):
    """
    Checking if the vowel is changing or not 
    input verb1 : verb base form (captured with lemmatization)
          verb3 : verb 3rd form (captured from sentence)
    return :
        status of change_vowel_bool and is_key_mismatch
    """
    change_vowel_bool = False
    is_key_mismatch = False
    verb1_count_dict = LetterCount(verb1)
    verb3_count_dict = LetterCount(verb3)
    print(verb1_count_dict,'\n',verb3_count_dict)
    for key,value in verb1_count_dict.items():
        #iterate over verb1 count dictionary
        if is_vowel(key):
            #checking verb character is vowel or not
            if key in verb3_count_dict:
                #checking same character is found in other verb dictionary or characters
                if verb1_count_dict[key] != verb3_count_dict[key]:
                    #if both the key count mismatch then status changes 
                    #print("word_count_missmatch")
                    change_vowel_bool  = True

            else:
                change_vowel_bool  = True
                is_key_mismatch = True
    return change_vowel_bool, is_key_mismatch

def is_weak_verb(verb1, verb3):
    #change_vowel_bool = False
    change_vowel_bool, is_key_mismatch = change_vowel_detect(verb1, verb3)
    week_verb_bool = False
    #if verb3.endswith('d') or verb3.endswith('t'):
    #week_verb_bool = True
    if verb1 == verb3:
        week_verb_bool = True
    if verb3.endswith('ed') and change_vowel_bool == False:
        week_verb_bool = True
    if (verb3.endswith('d') or verb3.endswith('t')) and is_key_mismatch == True :
        week_verb_bool = True
    return week_verb_bool

#testcases
print(is_weak_verb('Feed', 'Fed'))      # strong verb
print(is_weak_verb('love', 'loved'))    # Weak verb
print(is_weak_verb('meet', 'met'))      # Weak verb
print(is_weak_verb('put', 'put'))       # weak verb
print(is_weak_verb('wear', 'wore'))     # Strong verb
print(is_weak_verb('bring', 'brought')) # strong verb

既然你似乎需要英语,你可能想考虑一下使用。
如果你想自己实现它,祝你好运,玩得开心,但是如果你真的想涵盖所有情况,很容易在一长串异常中迷失…

我检查了提供的链接,但我不清楚如何使用我的问题陈述你能详细说明我的代码吗