Increase robustness of is_split_into_words
check: resolves ValueError
#39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #38, Closes #35
Hello!
Pull Request overview
is_split_into_words
checkDetails
In particular, before this PR, the tokenizer would use the first text in the prediction tokens to determine if we were dealing with: a string sentence, a list of string sentences, a sentence as a list of words, or a list of sentences each as a list of words. However, if the first sentence is just a single word, but you're passing a list of sentences, e.g.
['Avolon', 'Walmart - Milwaukee, WI']
or["Unknown", "Unknown", "Unknown", "Sentence 1", "Sentence 2"]
, then it would consider the inputs to be a single sentence.With this PR, the tokenizer will see them as a list of sentences.
However, do watch out for the following case: a list of sentences where each sentence is a single word. This is indistinguishable from a sentence as a list of words, and it will (perhaps unexpectedly) consider the text as the latter. I don't see a good solution for this, apart from splitting
predict
up intopredict
andpredict_single
or something.