From a72b4abb4839e8f319c7ef832a180bd40374928d Mon Sep 17 00:00:00 2001 From: Joshua Chin Date: Tue, 7 Jul 2015 15:47:37 -0400 Subject: [PATCH] revert to using global mecab_tokenize variable Former-commit-id: 189a5b9cd6bd36857c73ffd0bef86e38bc40da16 --- wordfreq/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wordfreq/__init__.py b/wordfreq/__init__.py index 5f2896a..bf68f14 100644 --- a/wordfreq/__init__.py +++ b/wordfreq/__init__.py @@ -43,7 +43,7 @@ def simple_tokenize(text): """ return [token.casefold() for token in TOKEN_RE.findall(text)] - +mecab_tokenize = None def tokenize(text, lang): """ Tokenize this text in a way that's straightforward but appropriate for @@ -57,7 +57,9 @@ def tokenize(text, lang): first, so that they can be expected to match the data. """ if lang == 'ja': - from wordfreq.mecab import mecab_tokenize + global mecab_tokenize + if mecab_tokenize is None: + from wordfreq.mecab import mecab_tokenize return mecab_tokenize(text) if lang == 'ar':