From 79b5d466202ecfeaae3d9472ed89d4f94ab66450 Mon Sep 17 00:00:00 2001 From: schneefux Date: Mon, 26 May 2014 14:49:45 -0700 Subject: vocabcompiler now takes arguments (useful for testing) --- boot/boot.py | 4 ++-- boot/vocabcompiler.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'boot') 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(" \n \n") f.close() # make language model - text2lm("../client/sentences.txt", "../client/languagemodel.lm") + text2lm(sentences, languagemodel) -- cgit v1.3.1