bjascob / LemmInflect

A python module for English lemmatization and inflection.
MIT License
258 stars 25 forks source link

suppress invalid upos warning #9

Closed kwhumphreys closed 3 years ago

kwhumphreys commented 3 years ago

for the expected case of OOV with unknown tag, when called from https://github.com/bjascob/LemmInflect/blob/master/lemminflect/core/Inflections.py#L124

bjascob commented 3 years ago

What is the use case where you're seeing this happen? My thinking is that if getAllInflectionsOOV is called with a upos that isn't recognized, or is None, the user is doing something wrong and needs to be notified with a warning.

kwhumphreys commented 3 years ago

I was trying to suppress the warning in this case

>>> getInflection('test', 'RP')
Invalid upos type = None

so that I can call getInflection for any tag, rather than pre-filtering. I can add a pre-filter, but it wasn't necessary for pyinflect.

bjascob commented 3 years ago

Asking the system to inflect a word into an "IN / Preposition or subordinating conjunction" seems like an error. The getAllInflections() call is made to return all possible inflection types (no tag required) but for getInlfection() you should only be asking the system to infect to valid types.

If you just want to suppress the warning message you can do...

import lemminflect
import logging
logging.getLogger('lemminflect.core.Inflections').setLevel(logging.ERROR)

This will change the logging level for just the Inflections class and won't impact anything else.

kwhumphreys commented 3 years ago

Understood. I can call tagToUpos to check for valid inflection tags first. But the warning is misleading because RP to PART is a valid upos, just not one that can be inflected.