mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-05 04:40:20 +03:00
don't overwrite fuzzy param value
This commit is contained in:
parent
ab28d686db
commit
ed8cb551dd
|
@ -1065,13 +1065,13 @@ def _get_extra_predicates_dict(attr, value_dict, vocab, predicate_types,
|
|||
regex=True))
|
||||
continue
|
||||
elif cls == _FuzzyPredicate:
|
||||
fuzzy = type_[len("FUZZY"):] # number after prefix
|
||||
fuzzy = int(fuzzy) if fuzzy else 0
|
||||
fuzz = type_[len("FUZZY"):] # number after prefix
|
||||
fuzz = int(fuzz) if fuzz else 0
|
||||
if isinstance(value, dict):
|
||||
# add predicates inside fuzzy operator
|
||||
output.extend(_get_extra_predicates_dict(attr, value, vocab, predicate_types,
|
||||
extra_predicates, seen_predicates,
|
||||
fuzzy=fuzzy))
|
||||
fuzzy=fuzz))
|
||||
continue
|
||||
predicate = cls(len(extra_predicates), attr, value, type_, vocab=vocab,
|
||||
regex=regex, fuzzy=fuzzy)
|
||||
|
|
|
@ -214,6 +214,22 @@ def test_matcher_match_fuzzy_set3(en_vocab):
|
|||
(doc.vocab.strings["GoogleNow"], 3, 4),
|
||||
]
|
||||
|
||||
def test_matcher_match_fuzzy_set4(en_vocab):
|
||||
rules = {
|
||||
"QUESTION": [[{"ORTH": {"FUZZY": {"IN": ["what"]},
|
||||
"NOT_IN": ["that"]}},
|
||||
{"ORTH": "do"}]]
|
||||
}
|
||||
matcher = Matcher(en_vocab)
|
||||
for key, patterns in rules.items():
|
||||
matcher.add(key, patterns, greedy="LONGEST")
|
||||
|
||||
words = ["what", "do", "you", "want"]
|
||||
doc = Doc(matcher.vocab, words=words)
|
||||
assert matcher(doc) == [
|
||||
(doc.vocab.strings["QUESTION"], 0, 2),
|
||||
]
|
||||
|
||||
|
||||
def test_matcher_match_fuzzyn1(en_vocab):
|
||||
rules = {
|
||||
|
|
Loading…
Reference in New Issue
Block a user