don't overwrite fuzzy param value

This commit is contained in:
Kevin Humphreys 2022-10-18 14:57:02 -07:00
parent ab28d686db
commit ed8cb551dd
2 changed files with 19 additions and 3 deletions

View File

@ -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)

View File

@ -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 = {