Skip to content

Commit

Permalink
fix code
Browse files Browse the repository at this point in the history
  • Loading branch information
m-yoshinaka committed Apr 7, 2020
1 parent 728b358 commit 9b1ffd0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ $ mv wiki-news-300d-1M-subword.bin model/

### Interactive mode
```
$ python run_sapphire.py
$ python run_sapphire.py model/wiki-news-300d-1M-subword.bin
```
To stop SAPPHIRE, enter `exit` when inputting a sentence.
To stop SAPPHIRE, enter `EXIT` when inputting a sentence.

### Usage of the SAPPHIRE module
```
Expand Down
6 changes: 4 additions & 2 deletions run_sapphire.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import sys
import fasttext

from sapphire import Sapphire, setting


def run_sapphire():
fasttext_path = sys.argv[1]
print(' * Loading pre-trained model ...', flush=True, end='')
model = fasttext.FastText.load_model(setting.FASTTEXT_PATH)
model = fasttext.FastText.load_model(fasttext_path)
print(' * - completed')

aligner = Sapphire(model)
Expand All @@ -16,7 +18,7 @@ def run_sapphire():
while sentence_src == '':
print('Input tokenized sentence (A)')
sentence_src = input('> ')
if sentence_src == 'exit':
if sentence_src == 'EXIT':
break

sentence_trg = ''
Expand Down
11 changes: 0 additions & 11 deletions sapphire/setting.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
import os
import sys

FASTTEXT_PATH = 'model/wiki-news-300d-1M-subword.bin'

HUGARIAN = False # word alignment option (default: grow-diag-final)

LAMBDA = 0.7 # threshold of word alignment candidate score
DELTA = 0.9 # threshold of phrase alignment candidate score
ALPHA = 0.05 # bias for length of phrase

if os.path.exists(FASTTEXT_PATH):
MODEL_PATH = 'model/wiki-news-300d-1M-subword.bin' # path of pre-trained word embedding model (default: fastText)
else:
print('Input the path of your pre-trained word embedding model.')
MODEL_PATH = input('> ')

0 comments on commit 9b1ffd0

Please sign in to comment.