You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromspacy.attrsimportNORM, LANGfromspacy.lang.arimportArabicDefaults, ArabicclassCustomArabicDefaults(ArabicDefaults):
lex_attr_getters=dict(ArabicDefaults.lex_attr_getters)
lex_attr_getters[LANG] =lambdatext: "ar"# language ISO codelex_attr_getters[NORM] =lambdax: normalize_arabic(
ArabicDefaults.lex_attr_getters[NORM](x)
)
# Create actual Language classclassCustomArabicBase(Arabic):
lang="ar"# Language ISO codeDefaults=CustomArabicDefaults# Override default
I'm upgrading the above class from spaCy 2.x to 3.x and encountering an issue with custom normalization. In spaCy 2.x, the code ArabicDefaults.lex_attr_getters[NORM](x) worked fine. However, in spaCy 3.x, it throws a KeyError because spacy.attrs.NORM is 67, but ArabicDefaults.lex_attr_getters no longer has the key 67. Instead, it returns a dictionary with key 10 which maps to the like_num function.
I'm not very experienced with spaCy, and I would appreciate any help on how to rewrite this class for spaCy 3.x while maintaining the custom normalization functionality.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm upgrading the above class from spaCy 2.x to 3.x and encountering an issue with custom normalization. In spaCy 2.x, the code
ArabicDefaults.lex_attr_getters[NORM](x)
worked fine. However, in spaCy 3.x, it throws aKeyError
becausespacy.attrs.NORM
is67
, butArabicDefaults.lex_attr_getters
no longer has the key67
. Instead, it returns a dictionary with key10
which maps to thelike_num function
.I'm not very experienced with spaCy, and I would appreciate any help on how to rewrite this class for spaCy 3.x while maintaining the custom normalization functionality.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions