obulat / zeyrek

Python morphological analyzer for Turkish language. Partial port of ZemberekNLP.
https://zeyrek.readthedocs.io/en/latest/
MIT License
47 stars 8 forks source link

Too many log messages causes an interrupt #17

Open bilative opened 2 years ago

bilative commented 2 years ago

Hi, I dont know if there is a way to cancel them I dont know but I hav problem with this.

actually I dont have so many sentences. I work with 250 lines of data. And in every line there is only 1 or 2 sentences. But after I run my loop, jupiter is interrapted bc there is so many logs. Is there any way to cancel logs?

cleansent = []
for sent in senteces:
     clean_sent =[]
     for word in sent:
          if word != “”:
               lemword = analyzer.lemmatize(word)
               clean_sent.append(lemword[0][1][0])
          lemsent.append(cleansent)

As I said log messages cause a interrupt :/

bilative commented 2 years ago

Hi again, I found a tricky solution to my problem. Like this:

from IPython.display import clear_output

cleansent = []
for sent in senteces:
     clean_sent =[]
     for word in sent:
          if word != “”:
               lemword = analyzer.lemmatize(word)
               clean_sent.append(lemword[0][1][0])

               clear_output(wait=True)
          lemsent.append(cleansent)

I couldn't prevent the logs but this method clean the outputs immediately in every iteration, So my code run well with thousand rows of data.

BUT: if there is any other clean way to ignore logs, I wanna hear it.

HarikalarKutusu commented 1 year ago

@bilative, in your own program you can use this to ignore lower-level logging from zeyrek:

import logging
logging.getLogger("zeyrek").setLevel(logging.ERROR)