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

Failure initializing Tagger has no error message #57

Open
polm opened this issue May 28, 2020 · 0 comments
Open

Failure initializing Tagger has no error message #57

polm opened this issue May 28, 2020 · 0 comments

Comments

@polm
Copy link

polm commented May 28, 2020

If you try to intialize a Tagger object with an output format that doesn't exist (like -Oasdf) then initialization will fail. On the command line this prints a reasonable error message, but if you call MeCab as a library (like in a wrapper from another language), getGlobalError returns an empty string. This can be confusing if the issue is a typo in the name of an output format or other minor issue.

The root cause of this issue is that when an invalid output format is used the global error message is set twice. First it's set here, in ModelImpl::open:

setGlobalError(error.c_str());

At this point everything is correct. But this function was called from createTagger, and when that sees that creating the Model failed it sets the error message again, this time to an empty string:

setGlobalError(tagger->what());

I first became aware of this issue due to trouble in mecab-python3.

An easy fix is to not to set the global error in createTagger. I'm not sure that's always correct, so it might be better to not set the global error if the new error string is empty - a check like that is in one version of setGlobalError already, but not the version normally used.

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