Skip to content

Commit

Permalink
make sentencepiece optional (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
msperber authored and neubig committed Jun 21, 2018
1 parent f125827 commit 0d094f5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 2 additions & 1 deletion examples/20_subword_sample.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Sampling subword units for subword regularization
# Sampling subword units for subword regularization
# Note that this requires 'sentencepiece' as an extra dependency
subword_sample: !Experiment
exp_global: !ExpGlobal
model_file: '{EXP_DIR}/models/{EXP}.mod'
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ cython
h5py
asteval
numpy
sentencepiece>=0.0.6
3 changes: 1 addition & 2 deletions xnmt/input_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
warnings.simplefilter("ignore", lineno=36)
import h5py

import sentencepiece as spm

from xnmt import logger
from xnmt.input import SimpleSentenceInput, AnnotatedSentenceInput, ArrayInput
from xnmt.persistence import serializable_init, Serializable
Expand Down Expand Up @@ -151,6 +149,7 @@ def __init__(self, model_file, sample_train=False, l=-1, alpha=0.1, vocab=None,
vocab: The vocabulary
include_vocab_reference: Whether to include the vocab with the input
"""
import sentencepiece as spm
self.subword_model = spm.SentencePieceProcessor()
self.subword_model.Load(model_file)
self.sample_train = sample_train
Expand Down

0 comments on commit 0d094f5

Please sign in to comment.