Closed himkt closed 8 years ago
Thanks, I will take a closer look at this during this weekend.
Brooke@iPhone
2016/01/22 16:49$B!"(Bhimkt notifications@github.com $B$N%a%C%;!<%8(B:
maybe related to this issue
https://github.com/buruzaemon/natto-py/blob/master/natto/mecab.py#L165
https://github.com/buruzaemon/natto-py/blob/master/natto/mecab.py#L167
$B!=(B Reply to this email directly or view it on GitHub.
Very interesting, this is immediately reproduce-able with @himkt's instructions...!
Oops! It's very strange...
My developent environment is bellow:
OS : OSX 10.11.2 Python: Anaconda3-2.4.0 natto : 0.7.0
If I noticed anything, I would report here.
I was also able to see this error on my Windows 7 laptop, and I am pretty sure I saw this at work on Linux environments as well. Thank you for raising this issue, @himkt.
I think natto needs to catch and handle/ignore the GeneratorExit exception that comes when the generator's close method is invoked.
c.f. http://stackoverflow.com/questions/18637048/avoid-exception-ignored-in-python-enhanced-generator
Looking at Mecab's src/tagger.cpp, line 784, you can see that the error "MECAB_NBEST request type is not set" comes when LatticeImpl::next() is invoked, meaning that this is happening after the Python generator's close method is called.
Solution is to explicitly trap the GeneratorExit error. Fixed, will make this available in the next release, tomorrow.
I see. Thx :+1:
Is this also fixed for Ubuntu? I seems to be having this exception in 0.8.0
Traceback (most recent call last): File "aiteacher.py", line 48, in <module> main(sys.argv) File "aiteacher.py", line 44, in main print(is_correct(question, user_sentence, correct_sentences, incorrect_sentences)) File "aiteacher.py", line 10, in is_correct return v2.is_match(user_sentence, correct_sentences, incorrect_sentences) File "/home/ubuntu/aiteacher-ai/src/v2.py", line 85, in is_match if compare(input_sentence, correct_sentence): File "/home/ubuntu/aiteacher-ai/src/v2.py", line 31, in compare input_nodes = convert_to_list(nm.parse(input_sentence, as_nodes=True)) File "/home/ubuntu/aiteacher-ai/src/v2.py", line 12, in convert_to_list for n in nodes: File "/usr/local/lib/python2.7/dist-packages/natto/mecab.py", line 413, in __parse_tonodes raise MeCabError(self.__bytes2str(self.__ffi.string(err))) natto.api.MeCabError: MECAB_NBEST request type is not set
The following code will cause the "natto.api.MeCabError: MECAB_NBEST request type is not set" error
# -*- coding: utf-8 -*-
from natto import MeCab
nm = MeCab('-F%m,%f[0],%f[1],%f[8]')
for n in nm.parse('私はアシャです', as_nodes=True):
print(n.feature)
I have confirmed @kohchuanhock -san's error can be reproduced.
This error has occurred when __%f[8]__
is used in the -F option.
It may be better to open the new issue.
To: @buruzaemon
@buruzaemon -san,
Thank you very much for your quick response. I have created new issue. https://github.com/buruzaemon/natto-py/issues/95
Thanks,
Thank you, @himkt. I will have a deeper look into @kohchuanhock's reported error, giving consideration to your steps for reproducing.
On Mon, Sep 18, 2017 at 5:25 PM, himkt notifications@github.com wrote:
I have confirmed @kohchuanhock-san's error can be reproduced. This error has occurred when %f[8] is used in the -F option.
To: @buruzaemon https://github.com/buruzaemon
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/buruzaemon/natto-py/issues/83#issuecomment-330156058, or mute the thread https://github.com/notifications/unsubscribe-auth/AAebkRaX4UKeHM9veZSu2ngRZaR0-lUuks5sjijdgaJpZM4HKKUW .
I got the error when I use break statement in for-loop.
I'm sorry but I don't have any clue about this error...