I execute a regex with python and I get the result I want
import re
s = """
LOONNEY BVBA 0431.568 836
Cock number 1542 222. 325
"""
expression = r"(\d+)(\.|\s)(\d+)?(\.|\s|\.\s)(\d+)"
this return :
0431.568 836
1542 222. 325
Then I transport the regex to do a spacy via rule-based and nothing happened
nlp = spacy.blank("en")
patterns = [
{
"label": "VAT_NUMBER",
"pattern": [{"TEXT": {"REGEX": r"(\d+)(\.|\s)(\d+)?(\.|\s|\.\s)(\d+)"}}]
}
]
#add patterns to ruler
ruler = EntityRuler(nlp)
nlp.add_pipe(ruler)
ruler.add_patterns(patterns)
#create the doc
doc = nlp(text)
#extract entities
for ent in doc.ents:
print (ent.text, ent.label_)
return nothing;
what's wrong? May be the or | or space \s?