本文整理汇总了Python中brain.Brain.get_modules方法的典型用法代码示例。如果您正苦于以下问题:Python Brain.get_modules方法的具体用法?Python Brain.get_modules怎么用?Python Brain.get_modules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类brain.Brain
的用法示例。
在下文中一共展示了Brain.get_modules方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compile
# 需要导入模块: from brain import Brain [as 别名]
# 或者: from brain.Brain import get_modules [as 别名]
def compile(sentences, dictionary, languagemodel):
"""
Gets the words and creates the dictionary
"""
modules = Brain.get_modules()
words = []
for module in modules:
words.extend(module.WORDS)
# for spotify module
words.extend(["MUSIC", "SPOTIFY"])
words = list(set(words))
# create the dictionary
pronounced = g2p.translateWords(words)
zipped = zip(words, pronounced)
lines = ["%s %s" % (x, y) for x, y in zipped]
with open(dictionary, "w") as f:
f.write("\n".join(lines) + "\n")
# create the language model
with open(sentences, "w") as f:
f.write("\n".join(words) + "\n")
f.write("<s> \n </s> \n")
f.close()
# make language model
text2lm(sentences, languagemodel)