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

inaccurate extract result #482

Open
curiosor opened this issue Dec 10, 2024 · 1 comment
Open

inaccurate extract result #482

curiosor opened this issue Dec 10, 2024 · 1 comment

Comments

@curiosor
Copy link

textblob.np_extractors don't work properly in some cases. As we have below code:

from textblob import TextBlob
from textblob.np_extractors import ConllExtractor, FastNPExtractor

extcr = ConllExtractor()
while True:
    ipt = input("type a setence > ")
    if ipt == "q":
        break
    blobs = TextBlob(ipt, np_extractor=extcr)
    print(blobs.noun_phrases)

then run a test:

type a setence > Adam saw a white cat sitting on the tree.
['adam', 'white cat'] # lost tree
type a setence > As soon as he passed the aisle, the other one took his seat, and lit up a cigarette.
[] # lost aisle, other one, seat, cigarette
type a setence > As soon as Adam passed the aisle, the other one took his seat, and lit up a cigarette.
['adam passed'] # wrong noun passed, lost aisle, other one, seat, cigarette
type a setence > As soon as Adam passed the cat, the other one took his seat, and lit up a cigarette.
['adam passed'] # wrong noun passed, lost cat, other one, seat, cigarette
type a setence > As soon as he passed the cat, the other one took his seat, and lit up a cigarette.
[] # lost cat, other one, seat, cigarette

Using textblob version: 0.18.0.post0

@curiosor
Copy link
Author

I found out that in textblob noun phrases need to be at least two words except names. Is there any configuration to customize this feature?
Besides, there are still problems

type a setence > As soon as he passed the narrow aisle, the other one took his empty seat, and lit up a half-used cigarette
['narrow aisle', 'empty seat']
type a setence > As soon as he passed the narrow aisle, the other one took his empty seat, and lit up a half used cigarette 
['narrow aisle', 'empty seat']
type a setence > As soon as he passed the narrow aisle, the other one took his empty seat, and lit up a handmade cigarette
['narrow aisle', 'empty seat', 'handmade cigarette']
type a setence > Adam saw a white cat sitting on the blooming cherry tree.
['adam', 'white cat', 'blooming cherry tree']
type a setence > Adam saw two white cats sitting on the blooming cherry tree 
['adam', 'blooming cherry tree']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant