From 2503ece871ac2d405c5851ffefe5d61b263896d5 Mon Sep 17 00:00:00 2001 From: schneefux Date: Mon, 15 Sep 2014 16:29:25 +0200 Subject: Use `Brain.get_modules()` in vocabcompiler --- client/vocabcompiler.py | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/client/vocabcompiler.py b/client/vocabcompiler.py index 1b4d94c..9bc34d2 100644 --- a/client/vocabcompiler.py +++ b/client/vocabcompiler.py @@ -4,14 +4,8 @@ """ import os -import sys -import glob - -mod_path = os.path.abspath('modules/') - -sys.path.append(mod_path) - import g2p +from brain import Brain def text2lm(in_filename, out_filename): @@ -35,21 +29,14 @@ def compile(sentences, dictionary, languagemodel): Gets the words and creates the dictionary """ - m = [os.path.basename(f)[:-3] - for f in glob.glob(os.path.dirname("../client/modules/") + "/*.py")] + modules = Brain.get_modules() words = [] - for module_name in m: - try: - exec("import %s" % module_name) - eval("words.extend(%s.WORDS)" % module_name) - except: - pass # module probably doesn't have the property - - words = list(set(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) -- cgit v1.3.1