Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unit tests #25

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions wordninja.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ def split(self, s):
texts = _SPLIT_RE.split(s)
assert len(punctuations) + 1 == len(texts)
new_texts = [self._split(x) for x in texts]
for i, punctuation in enumerate(punctuations):
new_texts.insert(2*i+1, punctuation)
# this just seems to add spaces (after PR #13) + the new delimiters in the regex to the result array, if they are already in the input string
# prior to PR # 13, it seems like it would add back anything in [^a-zA-Z0-9']+
# for i, punctuation in enumerate(punctuations):
# new_texts.insert(2*i+1, punctuation)
return [item for sublist in new_texts for item in sublist]


Expand Down Expand Up @@ -83,9 +85,7 @@ def best_match(i):
return reversed(out)

DEFAULT_LANGUAGE_MODEL = LanguageModel(os.path.join(os.path.dirname(os.path.abspath(__file__)),'wordninja','wordninja_words.txt.gz'))
_SPLIT_RE = re.compile(r"\s+")
_SPLIT_RE = re.compile(r"\/+|\\+|_+|-+|\s+")

def split(s):
return DEFAULT_LANGUAGE_MODEL.split(s)


return DEFAULT_LANGUAGE_MODEL.split(s)