writer / replaCy

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

sentence_has match_hook not working #68

Closed sam-writer closed 4 years ago

sam-writer commented 4 years ago

tested string: "Is that psycho, the hitchcock movie?"

match_dict entry:

{
    "psycho-noun": {
        "patterns": [
            {
                "POS": "DET"
            },
            {
                "LOWER": {
                    "IN": [
                        "psycho",
                        "wacko",
                        "whacko",
                        "loony"
                    ]
                },
                "POS": "NOUN",
                "DEP": {
                    "NOT_IN": [
                        "acomp",
                        "amod"
                    ]
                }
            }
        ],
        "match_hooks": [
            {
                "name": "sentence_has",
                "args": [
                    "movie",
                    "film",
                    "hitchcock",
                    "perkins",
                    "vera"
                ],
                "match_if_predicate_is": false
            }
        ],
        "suggestions": [
            [
                {
                    "TEXT": {
                        "IN": [
                            "a wild",
                            "a ridiculous",
                            "a confusing",
                            "an unpredictable",
                            "an impulsive",
                            "a reckless",
                            "a fearless",
                            "a baffling"
                        ]
                    }
                },
                {
                    "TEXT": "person"
                }
            ]
        ],
        "description": "This word was once commonly used to describe people with mental illness, but is now considered offensive. Why not use a more descriptive word instead?",
        "subcategory": "disability",
        "test": {
            "positive": [
                "What a psycho.",
                "She is a psycho",
                "What a whacko."
            ],
            "negative": [
                "I like to watch psycho, the hitchcock movie."
            ]
        }
    }
}

And it matches, which I feel like it shouldn't?

sam-writer commented 4 years ago

🤦 need to make match_hooks work in addition to match_hook