2013-07-05 37 views
2

有沒有辦法獲得比較/最高級的形容詞的積極形式? 例如。更好 - >好;最大 - >大。 我使用最新版本的NLTK。形容詞 - 最好的和比較積極的形式

+0

這個軟件似乎反其道而行之:http://www.clips.ua.ac.be/pages/pattern-en#comparative 也許可以從這裏的源代碼反向工程:HTTP:// www.clips.ua.ac.be/media/pattern-2.5.zip (雖然我不確定它是否使用NLTK) – arturomp

+0

nvm,它開始於'pattern2-5/pattern/text/en/inflect/_init_.py',但它是啓發式的...... :( – arturomp

回答

0

你可以嘗試使用從NLTK WordNet的光澤度/定義爲這樣:

from ntlk.corpus import wordnet as wn 

for ss in wn.all_synsets(): 
    if "(comparative of" in ss.definition: 
    comp = ss.definition.split("`")[1].split("'")[0] 
    for l in ss.lemma_names: 
     print l, comp 

但確實注意的是,只有13同義詞集用的定義比較信息編碼(用於NLTK v.2.0.4)。此外,它是不可能得到的比較字的分級(例如best > better > good

-1

你可以嘗試使用Pattern library

它爲您的使用情況了一些有用的API:

from pattern.en import comparative 
comparative(‘cool’) 

這給

'cooler' 

或爲最高級

from pattern.en import superlative 
superlative(‘cool’) 

這給

'coolest' 

網站演示:comparativesuperlative

+0

這是相反的問。 –

1

我碰到了同樣的問題來了,搜索沒有答案的網頁,然後發現它實際上可以與WordNetlemmatizer完成在nltk

回想WordNet具有那些簡化POS標籤:

n NOUN 
v VERB 
a ADJECTIVE 
s ADJECTIVE SATELLITE 
r ADVERB 

其中形容詞標籤,as,可用於歸一化。

>>> from nltk.stem.wordnet import WordNetLemmatizer 
>>> wnl = WordNetLemmatizer() 
>>> wnl.lemmatize('biggest', 'a') 
u'big' 
>>> wnl.lemmatize('better', 'a') 
u'good' 

這裏的第二個參數沒有魔術。如果留空,則默認爲'n'lemmatize()中的wordnet.NOUN。類似地,它應該明確地分別作爲'v''r'來標準化動詞和副詞。