Italian "po'" word is tokenized incorrectly
Your Environment
- spaCy version: 2.0.12
- Platform: Windows-10-10.0.16299-SP0
- Python version: 3.6.5
- Models: it
"Po'" (with the apostrophe) is the truncated form of "poco" (that means "a little") and must be considered as a single word, while currently spacy considers "po" and "'" as two tokens. Notice that "Po", without the apostrophe, is the name of the longhest river in Italy. But in this case it always has the capital P and is never followed by the apostrophe.
If I am not an Italian language speaker, but for this there are two things that you could do:
- Add a tokenizer special case.
import spacy
from spacy.symbols import ORTH, LEMMA
nlp = spacy.load('it')
nlp.tokenizer.add_special_case('Po"', [{ORTH: 'Po"', LEMMA: 'poco'}])
- Add it globally as a tokenizer exception and submit a pull request for that. As I can see here, there is no tokenizer_exceptions file for the Italian Language. You can create one and add this exception. You can find the template for creating this file here. For your case, it will be something like that:
# coding: utf8
from __future__ import unicode_literals
from ...symbols import ORTH, LEMMA, TAG, NORM, ADP, DET
# Exceptions should be added in the following format:
_exc = {
'Po"': [{ORTH: 'po"', LEMMA: 'poco'}]
}
TOKENIZER_EXCEPTIONS = _exc
Remember to update accordingly the init file for the italian language as well.
Hope it helps :)
Thanks.
Merging this with the master issue in #1642!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.