Skip to content

Commit

Permalink
added floyd tag to translate so synonym fetcher isn't called
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam authored and Sam committed Oct 10, 2018
1 parent f152112 commit 7eaf9d4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion start_here.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"spacy download en && spacy download fr\n",
"\n",
"Then this command to test the model:\n",
"python translate.py -load_weights weights -src_lang en -trg_lang fr\n",
"python translate.py -load_weights weights -src_lang en -trg_lang fr -floyd\n",
"\n",
"And if you want to test it on the CPU add the -no_cuda flag to the above command.\n",
"\n",
Expand Down
3 changes: 2 additions & 1 deletion translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def translate_sentence(sentence, model, opt, SRC, TRG):
indexed = []
sentence = SRC.preprocess(sentence)
for tok in sentence:
if SRC.vocab.stoi[tok] != 0:
if SRC.vocab.stoi[tok] != 0 or opt.floyd == True:
indexed.append(SRC.vocab.stoi[tok])
else:
indexed.append(get_synonym(tok, SRC))
Expand Down Expand Up @@ -72,6 +72,7 @@ def main():
parser.add_argument('-heads', type=int, default=8)
parser.add_argument('-dropout', type=int, default=0.1)
parser.add_argument('-no_cuda', action='store_true')
parser.add_argument('-floyd', action='store_true')

opt = parser.parse_args()

Expand Down

0 comments on commit 7eaf9d4

Please sign in to comment.