本文整理匯總了Python中nltk.corpus.reader.wordnet.NOUN屬性的典型用法代碼示例。如果您正苦於以下問題:Python wordnet.NOUN屬性的具體用法?Python wordnet.NOUN怎麽用?Python wordnet.NOUN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類nltk.corpus.reader.wordnet
的用法示例。
在下文中一共展示了wordnet.NOUN屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: lemmatize
# 需要導入模塊: from nltk.corpus.reader import wordnet [as 別名]
# 或者: from nltk.corpus.reader.wordnet import NOUN [as 別名]
def lemmatize(self, word, pos=NOUN):
lemmas = wordnet._morphy(word, pos)
return min(lemmas, key=len) if lemmas else word
示例2: testSysnetWordDissect
# 需要導入模塊: from nltk.corpus.reader import wordnet [as 別名]
# 或者: from nltk.corpus.reader.wordnet import NOUN [as 別名]
def testSysnetWordDissect(self):
test_string = 'cat.n.1'
test_subject = ProcessedWord(test_string)
self.failUnless(test_subject.raw_word() == "cat")
self.failUnless(test_subject.raw_part_of_speech() == NOUN)
self.failUnless(test_subject.word_index() == 1)
self.assertEqual(test_subject.word(), 'cat')
self.failUnless(test_subject.part_of_speech() == "noun")
self.failUnless(test_subject.word_index() == 1)
示例3: testDetectsAllPartsOfSpeech
# 需要導入模塊: from nltk.corpus.reader import wordnet [as 別名]
# 或者: from nltk.corpus.reader.wordnet import NOUN [as 別名]
def testDetectsAllPartsOfSpeech(self):
test_noun = ProcessedWord('noun.'+NOUN+'.1')
test_adverb = ProcessedWord('adverb.' + ADV + '.1')
test_adjective = ProcessedWord('adjective.' + ADJ + '.1')
test_adjective_satellite = ProcessedWord('adjective.' + ADJ_SAT + '.1')
test_verb = ProcessedWord('verb.' + VERB + '.1')
self.assertEqual('noun', test_noun.part_of_speech())
self.assertEqual('adverb', test_adverb.part_of_speech())
self.assertEqual('adjective', test_adjective.part_of_speech())
self.assertEqual('adjective', test_adjective_satellite.part_of_speech())
self.assertEqual('verb', test_verb.part_of_speech())
示例4: testHumanizesDashedAndAccentedWords
# 需要導入模塊: from nltk.corpus.reader import wordnet [as 別名]
# 或者: from nltk.corpus.reader.wordnet import NOUN [as 別名]
def testHumanizesDashedAndAccentedWords(self):
test_complex = ProcessedWord('turnip_jack-o\'-lantern.'+NOUN+'.1')
self.assertEqual('turnip jack-o\'-lantern', test_complex.word())