mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 18:06:29 +03:00
Fix expand_exc to make sure it returns combined dict
This commit is contained in:
parent
824d09bb74
commit
ee7dcf65c9
|
@ -150,7 +150,7 @@ def update_exc(base_exceptions, *addition_dicts):
|
||||||
# overlap = set(exc.keys()).intersection(set(additions))
|
# overlap = set(exc.keys()).intersection(set(additions))
|
||||||
# assert not overlap, overlap
|
# assert not overlap, overlap
|
||||||
exc.update(additions)
|
exc.update(additions)
|
||||||
expand_exc(exc, "'", "’")
|
exc = expand_exc(exc, "'", "’")
|
||||||
return exc
|
return exc
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,13 +159,13 @@ def expand_exc(excs, search, replace):
|
||||||
fixed = dict(token)
|
fixed = dict(token)
|
||||||
fixed[ORTH] = fixed[ORTH].replace(search, replace)
|
fixed[ORTH] = fixed[ORTH].replace(search, replace)
|
||||||
return fixed
|
return fixed
|
||||||
updates = {}
|
new_excs = dict(excs)
|
||||||
for token_string, tokens in excs.items():
|
for token_string, tokens in excs.items():
|
||||||
if search in token_string:
|
if search in token_string:
|
||||||
new_key = token_string.replace(search, replace)
|
new_key = token_string.replace(search, replace)
|
||||||
new_value = [_fix_token(t, search, replace) for t in tokens]
|
new_value = [_fix_token(t, search, replace) for t in tokens]
|
||||||
updates[new_key] = new_value
|
new_excs[new_key] = new_value
|
||||||
return updates
|
return new_excs
|
||||||
|
|
||||||
|
|
||||||
def normalize_slice(length, start, stop, step=None):
|
def normalize_slice(length, start, stop, step=None):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user