aboSamoor / polyglot

Multilingual text (NLP) processing toolkit
http://polyglot-nlp.com
Other
2.31k stars 337 forks source link

unbound local variable in text.py #109

Closed hgluka closed 7 years ago

hgluka commented 7 years ago

I encountered this error while using the NER of polyglot:

Traceback (most recent call last):
  File "data_extraction.py", line 177, in <module>
    output_frame = output_frame.append(parse_company_name(row['stranka'].lower()), ignore_index=True)
  File "data_extraction.py", line 102, in parse_company_name
    for entity in text.entities:
  File "/home/luca/projects/.venvs/mlpython/lib/python3.6/site-packages/polyglot/decorators.py", line 20, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/luca/projects/.venvs/mlpython/lib/python3.6/site-packages/polyglot/text.py", line 140, in entities
    if tag != u'O':
UnboundLocalError: local variable 'tag' referenced before assignment

There seems to be an easy fix, it looks like a simple indentation problem. I'll submit a PR once I set everything up.

ddefranza commented 4 years ago

I am still seeing this error in Polyglot version 16.7.4. Any ideas for a workaround?

Nilanjan96 commented 4 years ago

@ddefranza you might be passing an empty string. Check text.entities if it is so.