Hi I tried to match the words using spacy for the texts like
1 cups 1 1/2 cups 1 1/2-inch
To achieve this, I created matcher pattern as below.
pattern1 = [{'POS':'NUM'},
{'POS':'NUM','OP':'?'},{'POS':'NOUN'},];
# number number noun pattern
pattern2=[{'POS':'NUM'},{'POS':'NUM','OP':'?'},{"ORTH": "-",'OP':'?'},
{'POS': 'NOUN'}];
# number after number but optional to cover both '2 inch' and '2 1/2 inch'
# it should also cover '2 1/2-inch' so put 'ORTH':'-' but optional
However, when I run the matcher, it only returns one pattern which is number followed by noun like below.
matcher.add('Measurepattern',None,pattern1)
matcher.add('Measurepattern',None,pattern2)
matches=matcher(test_token)
matches
for token,start,end in matches:
print(test_token[start:end])
//2 teaspoons
//1 teaspoon
//1 cup
Why is that and how do I fix this?
Thank you