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

blob.noun_phrases fails with ConllExtractor when blob is constructed with a str in PY2 #189

Open
jschnurr opened this issue Jan 25, 2018 · 0 comments

Comments

@jschnurr
Copy link
Collaborator

@jschnurr jschnurr commented Jan 25, 2018

In the docs for advanced noun phrase chunkers, ConllExtractor is called on a string, like this:

from textblob.np_extractors import ConllExtractor
extractor = ConllExtractor()
blob = TextBlob("Python is a high-level programming language.", np_extractor=extractor)

However, on Python 2.7, calling blob.noun_phrases on this object raises an exception. The underlying issue is that ConllExtractor depends on the PatternTagger.tag() method, which throws an AttributeError when given a str, as illustrated in this minimal example:

from textblob.taggers import PatternTagger
PatternTagger().tag('hi')
Traceback (most recent call last):
  File "test.py", line 2, in <module>
    PatternTagger().tag('hi')
  File "/home/jschnurr/.virtualenvs/btest/local/lib/python2.7/site-packages/textblob/en/taggers.py", line 23, in tag
    text = text.raw
AttributeError: 'str' object has no attribute 'raw'   

Specifying Unicode works properly:

from textblob.taggers import PatternTagger
PatternTagger().tag(u'hi')
[(u'hi', u'UH')]
@jschnurr jschnurr changed the title ConllExtractor fails with AttributeError when passed a str in PY2 blob.noun_phrases fails with ConllExtractor when blob is constructed with a str in PY2 Jan 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.