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
This isn't necessarily a problem (it could be useful), but it is not consistent with the function name. I see two possibible fixes:
Change internals to re.sub(r'\b{}\b'.format(re.escape(key)), value, s). Note that \b is the word boundary mark.
Rename the function to ReplaceRegexes (or keep both). The example should reflect the current behavior. Regex replaces can be nice: you can for instance use ReplaceWords({r'\b(foo|bar)baz\b': r'\1'}) to remove 'baz' from 'foobaz' and 'barbaz' but keep it in all other cases (artificial example, I know).
The above indicates that this function (or these functions, if you go for the second option) can use a unit test. This is currently missing..
Finally, the transform is not included in transforms.__all__, and as a result it isn't directly available on jiwer, but only as part of jiwer.transforms.
The text was updated successfully, but these errors were encountered:
There are a few issues with the
ReplaceWords
transform. Most importantly, due to the way it's implemented, it actually alters any matching substring:ReplaceWords({'foo': 'bar'})('foobar')
returnsbarbar
This isn't necessarily a problem (it could be useful), but it is not consistent with the function name. I see two possibible fixes:
re.sub(r'\b{}\b'.format(re.escape(key)), value, s)
. Note that\b
is the word boundary mark.ReplaceRegexes
(or keep both). The example should reflect the current behavior. Regex replaces can be nice: you can for instance useReplaceWords({r'\b(foo|bar)baz\b': r'\1'})
to remove 'baz' from 'foobaz' and 'barbaz' but keep it in all other cases (artificial example, I know).The above indicates that this function (or these functions, if you go for the second option) can use a unit test. This is currently missing..
Finally, the transform is not included in
transforms.__all__
, and as a result it isn't directly available onjiwer
, but only as part ofjiwer.transforms
.The text was updated successfully, but these errors were encountered: