custom pipeline component (phuzzymatcher) not working with error (TypeError: 'int' object is not iterable) #12087
-
I'm trying to edit pipeline component (PhuzzyMatcher) for fuzzy matching created by jackmen to work with Spacy v3.x, as the original build works only with Spacy v2.x, but I'm having problems even though all I'm adding is the Language.Factory decorator. def fuzzy_matcher(features, document, match=None): def fuzzy_matcher_stopwords(features, document, match=None, stop_words=None): nlp = spacy.blank('en') @Language.factory("phuzzymatcher") class PhuzzyMatcher:
My error code: TypeError: 'int' object is not iterable If I run the different functions separately, it works, and there is nothing in the fuzzy_matcher function that is not iterable as far as I can see. EDIT2: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Info about spaCy
|
Beta Was this translation helpful? Give feedback.
-
Would you mind re-formatting the code in the original post such that it's formatted correctly and whitespace is preserved? You can also attach the .py file(s) directly to the post, but you might have to change the file extension due to GitHub's restrictions. |
Beta Was this translation helpful? Give feedback.
-
Seems like your issue stems from the fact that the positional parameters passed to the @Language.factory("phuzzymatcher")
def create_phuzzymatcher(
nlp: Language, name: str, set: list, match: int, label=None, stop_words=None
):
return PhuzzyMatcher(nlp, set, match, label, stop_words)
class PhuzzyMatcher:
def __init__(self, nlp, name, set, match, label, stop_words=None):
... Passing On a related note, when spaCy v3.5 is released, it will include fuzzy matching support in the |
Beta Was this translation helpful? Give feedback.
Seems like your issue stems from the fact that the positional parameters passed to the
PhuzzyMatcher
constructor are incorrect:Passing
name
beforeset
resolves the error you're seeing.On a related note, when spaCy v3.5 is released, it will include fuzzy matching support in the
Matcher
class.