writer / replaCy

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

Simple phrase-based context matching #35

Closed sam-writer closed 4 years ago

sam-writer commented 4 years ago

Let's say you want to match against apples unless it is part of a Rick and Morty reference. Rather than build a classifier, you decide you will match the word apples unless it is in the phrase hungry for apples or in a sentence with the words/phrases "rick", "morty", "jerry", "wubba lubba dub dub".

This is a simple, often-accurate-enough solution to the problem of context, and we should have match hooks for this. I imagine them looking like:

        "match_hook": [
            {
                "name": "part_of_phrase",
                "args": "hungry for apples",
                "match_if_predicate_is": false
            },
            {
                "name": "sentence_has",
                "args": ["rick", "morty", "jerry", "wubba lubba dub dub"],
                "match_if_predicate_is": false
            }
        ]