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

Is it possible to unset output-format-type? #25

Closed
polm opened this issue Mar 27, 2019 · 1 comment
Closed

Is it possible to unset output-format-type? #25

polm opened this issue Mar 27, 2019 · 1 comment

Comments

@polm
Copy link
Collaborator

polm commented Mar 27, 2019

I would like to specify a custom format string even if the user has an output-format-type specified in their mecabrc. As described in taku910/mecab#41, the way to do this on the command line is to give an argument like -O "". So I tried this:

tagger = MeCab.Tagger('-O ""')

Unfortunately this results in a RuntimeError. I tried escaping the quotes without effect. I guess something about the way the argument string is passed to the Mecab library is different than its own internal argument handling?

For reference, the reason I want to specify a format string is explained in explosion/spaCy#3491.

@zackw
Copy link
Collaborator

zackw commented Apr 16, 2019

Unfortunately, the SWIG interface definition file that we use only exposes the C++-level Tagger constructor that takes a single string containing command-line options. That constructor doesn't implement any shell quotation syntax; it blindly splits its input on whitespace. It is therefore not possible to set the -O option's argument to the empty string using this constructor.

There is another constructor that takes an array of command-line options. If we exposed that constructor, you could write something like

tagger = MeCab.Tagger(["-O", ""])

and it would work. Unfortunately, I do not understand SWIG well enough to know how to make that change. If you can figure it out I would be glad to merge your patch. (Please note that both the Tagger and Model classes should be changed.)

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

No branches or pull requests

2 participants