writer / replaCy

spaCy match and replace, maintaining conjugation
https://pypi.org/project/replacy/
MIT License
34 stars 8 forks source link

#30 reference matched tokens and #31 explicit inflection #39

Closed samhavens closed 4 years ago

samhavens commented 4 years ago

Allow suggestions to not have text but instead just reference a pattern token by 0-index from start of pattern, and also allow tokens like this to be explicitly inflected, closing #30 and #31.

Thoughts

this is pretty cool, you can test it with:

from replacy import ReplaceMatcher
from replacy.db import load_json
import spacy

nlp = spacy.load("en_core_web_sm")
rmatcher = ReplaceMatcher(nlp)

span = rmatcher("He has eat that")
# span._.suggestions = ['has eaten that']

Which isn't that cool until you look at the pattern and see how general it is. I'm not sure how much more is needed for effective LT feature parity.

HOWEVER, since you can reference pattern tokens by ID... it makes TEMPLATE_ID feel kinda unneeded, we could change that to FROM_PATTERN and just use the token ID. Thoughts @melisa-qordoba ?

samhavens commented 4 years ago

sigh just realized my personal computer has the max line length set to 80, and different rules for Markdown and JSON formatting, so there are extra formatting diffs... Let me know if I need to change that.

Maybe we can check the correct .vscode/settings.json into git so it overrides local settings?

Sorry