Skip to content

Commit

Permalink
try/except on nlup (detector_morse) import
Browse files Browse the repository at this point in the history
  • Loading branch information
hobs committed Nov 24, 2019
1 parent 411f9e1 commit 7561def
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ gensim>=3.4.0,<4.0
jupyter>=1.0.0,<3.0.0 # pandas>=0.23.4,<0.30.0
matplotlib>=2.2.3,<2.3.0
nltk>=3.2.5,<3.5.0
nlup==0.5
# nlup==0.5
pandas>=0.24.2,<0.25.0
pip>=18.0
plotly>=3.2.1,<3.4.0
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ include_package_data = True
package_dir =
=src
# Add here dependencies of your project (semicolon-separated), e.g.
install_requires = coverage; future; fuzzywuzzy; jupyter; matplotlib; nltk; nlup==0.5; pandas; pip; pypandoc; python-Levenshtein; python-slugify; scikit-learn; scipy; plotly; seaborn; tqdm; wheel; gensim;
install_requires = coverage; future; fuzzywuzzy; jupyter; matplotlib; nltk; pandas; pip; pypandoc; python-Levenshtein; python-slugify; scikit-learn; scipy; plotly; seaborn; tqdm; wheel; gensim;
# Add here test requirements (semicolon-separated)
tests_require = pytest; pytest-cov

Expand Down
9 changes: 6 additions & 3 deletions src/pugnlp/detector_morse.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@
from future import standard_library
standard_library.install_aliases() # noqa

from collections import namedtuple
import logging
from re import finditer, match, search
from collections import namedtuple

from nlup import case_feature, isnumberlike, listify, BinaryAveragedPerceptron, BinaryConfusion, IO, JSONable

from .penn_treebank_tokenizer import word_tokenize

logger = logging.getLogger(__name__)
try:
from nlup import case_feature, isnumberlike, listify, BinaryAveragedPerceptron, BinaryConfusion, IO, JSONable
except ImportError:
logger.error("detector_morse disabled because Kyle Gorman's nlup sentence boundary detector has not been installed.")
# FIXME(kbg) can surely avoid full-blown tokenization


Expand Down
21 changes: 13 additions & 8 deletions src/pugnlp/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,25 @@
import os
import re
from itertools import chain
import logging

import nltk.stem

from pugnlp.detector_morse import Detector
from pugnlp.detector_morse import slurp
from pugnlp.futil import find_files
# from .penn_treebank_tokenizer import word_tokenize
import nlup

import nltk.stem
from .detector_morse import Detector
from .detector_morse import slurp
from .futil import find_files
from .constants import DATA_PATH
from .futil import generate_files
from .util import stringify, passthrough
from .regexes import CRE_TOKEN, RE_NONWORD

# from .penn_treebank_tokenizer import word_tokenize

from pugnlp.regexes import CRE_TOKEN, RE_NONWORD
logger = logging.getLogger(__name__)
try:
import nlup
except ImportError:
logger.error("detector_morse disabled because Kyle Gorman's nlup sentence boundary detector has not been installed.")


class Split(object):
Expand Down

0 comments on commit 7561def

Please sign in to comment.