mirror of https://github.com/explosion/spaCy.git
Raise custom ImportError if importing janome fails
This commit is contained in:
parent
949ad6594b
commit
d730eb0c0d
|
@ -14,6 +14,9 @@ class Japanese(Language):
|
|||
lang = 'ja'
|
||||
|
||||
def make_doc(self, text):
|
||||
from janome.tokenizer import Tokenizer
|
||||
try:
|
||||
from janome.tokenizer import Tokenizer
|
||||
except ImportError:
|
||||
raise ImportError("The Japanese tokenizer requires the Janome library: https://github.com/mocobeta/janome")
|
||||
words = [x.surface for x in Tokenizer().tokenize(text)]
|
||||
return Doc(self.vocab, words=words, spaces=[False]*len(words))
|
||||
|
|
Loading…
Reference in New Issue