summaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2014-05-26 14:49:45 -0700
committerschneefux <schneefux+commit@schneefux.xyz>2014-05-26 14:49:45 -0700
commit79b5d466202ecfeaae3d9472ed89d4f94ab66450 (patch)
tree3fc810374797e4e934f55a61bf323f8af87ff565 /boot
parentb0c595cc234f490bf41748f80b9b4523b88323be (diff)
downloadjasper-client-79b5d466202ecfeaae3d9472ed89d4f94ab66450.tar.gz
jasper-client-79b5d466202ecfeaae3d9472ed89d4f94ab66450.zip
vocabcompiler now takes arguments (useful for testing)
Diffstat (limited to 'boot')
-rwxr-xr-xboot/boot.py4
-rw-r--r--boot/vocabcompiler.py10
2 files changed, 7 insertions, 7 deletions
diff --git a/boot/boot.py b/boot/boot.py
index 56bcc7e..b33fd34 100755
--- a/boot/boot.py
+++ b/boot/boot.py
@@ -22,7 +22,7 @@ def configure():
print "CONNECTED TO INTERNET"
print "COMPILING DICTIONARY"
- vocabcompiler.compile()
+ vocabcompiler.compile("../client/sentences.txt", "../client/dictionary.dic", "../client/languagemodel.lm")
print "STARTING CLIENT PROGRAM"
@@ -49,7 +49,7 @@ def configure():
print "CONNECTED TO INTERNET"
print "COMPILING DICTIONARY"
- vocabcompiler.compile()
+ vocabcompiler.compile("../client/sentences.txt", "../client/dictionary.dic", "../client/languagemodel.lm")
print "STARTING CLIENT PROGRAM"
diff --git a/boot/vocabcompiler.py b/boot/vocabcompiler.py
index 5c00675..a3aaf66 100644
--- a/boot/vocabcompiler.py
+++ b/boot/vocabcompiler.py
@@ -23,7 +23,7 @@ def text2lm(in_filename, out_filename):
os.system(cmd)
def idngram2lm(in_filename, out_filename):
- cmd = "idngram2lm -idngram temp.idngram -vocab ../client/sentences.txt -arpa %s" % (
+ cmd = "idngram2lm -idngram temp.idngram -vocab %s -arpa %s" % (
in_filename, out_filename)
os.system(cmd)
@@ -31,7 +31,7 @@ def text2lm(in_filename, out_filename):
idngram2lm(in_filename, out_filename)
-def compile():
+def compile(sentences, dictionary, languagemodel):
"""
Gets the words and creates the dictionary
"""
@@ -57,14 +57,14 @@ def compile():
zipped = zip(words, pronounced)
lines = ["%s %s" % (x, y) for x, y in zipped]
- with open("../client/dictionary.dic", "w") as f:
+ with open(dictionary, "w") as f:
f.write("\n".join(lines) + "\n")
# create the language model
- with open("../client/sentences.txt", "w") as f:
+ with open(sentences, "w") as f:
f.write("\n".join(words) + "\n")
f.write("<s> \n </s> \n")
f.close()
# make language model
- text2lm("../client/sentences.txt", "../client/languagemodel.lm")
+ text2lm(sentences, languagemodel)