我已經看過pattern.en
的conjugate
,但它只綴成幾個表格,我寧可不要坐下來,程序中的所有例外的規則,讓我做動詞變化,如如何將英語單詞與Python中的漸進式表單結合起來?
- 免費 - 釋放
- 吃 - 吃
- 洗澡 - 洗澡
- 是 - 是
- 禁令 - 禁止
nltk
有詞幹,但它似乎沒有反向操作,至少從搜索StackOverflow。這似乎是一個非常基本的NLP任務,但是我找不到任何現代化的東西,它在Python中是這樣做的。任何一般的共軛工具都不錯,儘管英語中的漸進式形式並沒有我所知道的不規則性。
我也想看看是否有此規則的例外,這可能工作作爲備用功能:
def present_to_progressive(x):
vowels = set(['a','e','i','o','u'])
size = len(x)
if size == 2:
return x + 'ing'
elif x[size - 2:] == 'ie':
return x[:(size-2)] + 'ying'
elif x[size - 1] not in vowels and x[size - 2] not in vowels:
return x + 'ing'
elif x[size - 1] == 'e' and x[size-2] not in vowels:
return x[0:(size-1)] + 'ing'
elif x[size - 1] not in vowels and x[size-2] in vowels:
if x[size - 3] not in vowels:
return x + x[size-1] + 'ing'
else:
return x + 'ing'
else:
return x + 'ing'
編輯:新增案例「即」動詞
好吧,我想我最初忽略了方面參數。這應該爲我的目的做伎倆。 –