Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging problem with simplemma #11

Closed
dokato opened this issue Jun 18, 2022 · 1 comment
Closed

Logging problem with simplemma #11

dokato opened this issue Jun 18, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@dokato
Copy link

dokato commented Jun 18, 2022

Not sure necessarily if this problem should be addressed here, but I discovered it while using the package, so I thought I'd report.

In my app that uses simplemma, I have a logger configured like this:

logging.basicConfig(level=logging.DEBUG,
                    handlers=[
                     logging.FileHandler("ocr.log"),
                     logging.StreamHandler(sys.stdout)
                    ])

But this causes errors, when it gets to line:
https://github.com/adbar/simplemma/blob/main/simplemma/simplemma.py#L389

--- Logging error ---
Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/logging/__init__.py", line 1085, in emit
    msg = self.format(record)
  File "/opt/conda/lib/python3.8/logging/__init__.py", line 929, in format
    return fmt.format(record)
  File "/opt/conda/lib/python3.8/logging/__init__.py", line 668, in format
    record.message = record.getMessage()
  File "/opt/conda/lib/python3.8/logging/__init__.py", line 373, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/opt/conda/lib/python3.8/threading.py", line 890, in _bootstrap
    self._bootstrap_inner()
  File "/opt/conda/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/home/user/./app/action.py", line 40, in <listcomp>
    text = " ".join([simplemma.lemmatize(x, lang=('it','en')) for x in text.split(' ') if len(x)])
  File "/opt/conda/lib/python3.8/site-packages/simplemma/simplemma.py", line 389, in lemmatize
    LOGGER.debug(token, candidate, 'found in %s', i)

Any other packages seem to work just fine with my logging definition.

@adbar adbar added the bug Something isn't working label Jun 27, 2022
adbar added a commit that referenced this issue Jun 27, 2022
@adbar
Copy link
Owner

adbar commented Jun 27, 2022

Hi @dokato, thanks for pointing that out, it is a bug indeed. I was able to fix it in the commit above.

Please note that you might want to use the text_lemmatizer() function in your code instead of splitting the input on spaces.

@adbar adbar closed this as completed Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants