https://github.com/explosion/spaCy/issues/882과 같이 규칙 기반 검색을 사용하여 spaCy에서 '$ 125.00/share'와 (과) 일치하는 항목을 찾으려고했습니다.spaCy 'IS_SPACE'플래그가 작동하지 않습니다.
nlp = en_core_web_sm.load()
matcher = Matcher(nlp.vocab)
doc = nlp(u'$125.00/share, $ 125/share, $ 125.00/share, $ 125 . 00/share')
token_pattern = [{'NORM': '$'}, {'IS_DIGIT': True}, {'ORTH': '.', 'OP': '?'},
{'IS_DIGIT': True, 'OP': '?'}, {'ORTH': '/'}, {'LOWER': 'share'}]
def matched_pattern (matcher, doc, i, matches):
match_id, start, end = matches[i]
span = doc[start: end]
print ('matched!', span)
matcher.add('SharePrice', matched_pattern, token_pattern)
matches = matcher(doc)
을하려고 할 때 그러나, 나는 다시 얻을
('일치!', $ (125)/주)('맞춘다!', $ (125). 00/주)
대신 '$ 125.00/share'와 같은 패턴을 사이에 공백없이 일치 시키려고합니다. 시도 할 때
token_pattern = [{'NORM': '$'}, {'IS_SPACE': False}, {'IS_DIGIT': True}, {'IS_SPACE': False},{'ORTH': '.', 'OP': '?'}, {'IS_SPACE': False},
{'IS_DIGIT': True, 'OP': '?'}, {'IS_SPACE': False}, {'ORTH': '/'}, {'IS_SPACE': False}, {'LOWER': 'share'}]
내 표현이 어떤 패턴과도 일치하지 않습니다. 도와주세요!