本文整理汇总了Python中lexicon.Lexicon.add_word方法的典型用法代码示例。如果您正苦于以下问题:Python Lexicon.add_word方法的具体用法?Python Lexicon.add_word怎么用?Python Lexicon.add_word使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lexicon.Lexicon
的用法示例。
在下文中一共展示了Lexicon.add_word方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_lexicon
# 需要导入模块: from lexicon import Lexicon [as 别名]
# 或者: from lexicon.Lexicon import add_word [as 别名]
def create_lexicon():
lexicon = Lexicon()
words_file = open(ENGLISH_WORDS, 'r')
print '=== CREATING LEXICON ==='
print '=== READING WORDS FILE ==='
for word in words_file:
lexicon.add_word(word)
print '=== LEXICON CREATED ==='
return lexicon
示例2: make_lexicon
# 需要导入模块: from lexicon import Lexicon [as 别名]
# 或者: from lexicon.Lexicon import add_word [as 别名]
def make_lexicon(self):
lexicon = Lexicon()
the = Lexical("ART", {"ROOT": "?the", "AGR": "?v"})
the.set_variable("?the", ["the"])
the.set_variable("?v", ["3s", "3p"])
lexicon.add_word("the", [the])
dog = Lexical("N", {"ROOT": "?dog1", "AGR": "?3s"})
dog.set_variable("?3s", ["3s"])
dog.set_variable("?dog1", ["DOG1"])
lexicon.add_word("dog", [dog])
return lexicon