本文整理匯總了Python中nltk.corpus.wordnet.ADJ_SAT屬性的典型用法代碼示例。如果您正苦於以下問題:Python wordnet.ADJ_SAT屬性的具體用法?Python wordnet.ADJ_SAT怎麽用?Python wordnet.ADJ_SAT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類nltk.corpus.wordnet
的用法示例。
在下文中一共展示了wordnet.ADJ_SAT屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: wup_similarity
# 需要導入模塊: from nltk.corpus import wordnet [as 別名]
# 或者: from nltk.corpus.wordnet import ADJ_SAT [as 別名]
def wup_similarity(tagx, tagy):
scores = []
for pos in [wn.NOUN, wn.VERB, wn.ADJ, wn.ADJ_SAT, wn.ADV]:
try:
synsetx = wn.synset('%s.%s.01' % (tagx,pos))
synsety = wn.synset('%s.%s.01' % (tagy,pos))
score = synsetx.wup_similarity(synsety)
if score is None:
score = 0
except Exception, e:
score = 0
scores.append(score)
示例2: lemmatize_term
# 需要導入模塊: from nltk.corpus import wordnet [as 別名]
# 或者: from nltk.corpus.wordnet import ADJ_SAT [as 別名]
def lemmatize_term(term, pos=None):
if pos is None:
synsets = wordnet.synsets(term)
if not synsets:
return term
pos = synsets[0].pos()
if pos == wordnet.ADJ_SAT:
pos = wordnet.ADJ
return nltk.WordNetLemmatizer().lemmatize(term, pos=pos)