summaryrefslogtreecommitdiff
path: root/client/vocabcompiler.py
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2014-09-15 16:29:25 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2014-09-15 16:29:53 +0200
commit2503ece871ac2d405c5851ffefe5d61b263896d5 (patch)
tree0d097161c5947c4d0d189ba23351b7cf6d1d9948 /client/vocabcompiler.py
parentf04aee9a073ef05f04d5300de578d327d464ebbf (diff)
downloadjasper-client-2503ece871ac2d405c5851ffefe5d61b263896d5.tar.gz
jasper-client-2503ece871ac2d405c5851ffefe5d61b263896d5.zip
Use `Brain.get_modules()` in vocabcompiler
Diffstat (limited to 'client/vocabcompiler.py')
-rw-r--r--client/vocabcompiler.py23
1 files 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)