Skip to content

Conversation

@eggplants
Copy link

1ea30b1 でのModelクラスでのerror_checkオプション追加をTaggerクラスにも行いました。

@polm
Copy link
Collaborator

polm commented May 22, 2021

すみません、このPRの目的はもう少し説明いただけないでしょうか?Taggerは既にerror_infoを使っているのでエラーメッセージが改善されるようには見えません。どういう使い方を想定していますでしょうか。

@eggplants
Copy link
Author

try:
    t = MeCab.Tagger('', True)
except RantimeError:
    t = MeCab.Tagger('-r /dev/null')

のような場合、2行目のエラー文は必要ないので抑制したいのです。

@eggplants eggplants changed the title Improve failure message in class Tagger Add an option to suppress stderr in Tagger class May 22, 2021
@polm
Copy link
Collaborator

polm commented May 30, 2021

返事が遅くなってすみません。PRの目的がよく分かりました、確かに直接stderrに出力するのは少し強引でした。引数を増やすより、エラーメッセージを普通にRuntimeErrorにまとめた方が良いと思ったのでmasterの方でそうしました。

しかしこれはどういう状況だと便利なのかはまだよく分かりません。この手のエラーはだいたい環境構築に問題がある場合に発生するので、普段はエラー発生→環境の問題を解決→エラーがもう発生しないという流れで現れると想定しています。どのような状況だったら以上のようなコードで解決できますでしょうか。

@eggplants eggplants closed this Jun 7, 2021
@eggplants
Copy link
Author

eggplants commented Jun 7, 2021

もともとCLIツールでこのライブラリを使用する際に邪魔な出力を抑制しやすくしたいと思ってPRしました。
最新のmasterへの変更のようにエラーメッセージとして出力するようでしたら、扱いやすいので助かります。

polm added a commit to polm/fugashi that referenced this pull request Jul 24, 2021
This is conceputally the same as the change in mecab-python3 as a result
of SamuraiT/mecab-python3#67. Instead of the
initialization error producing output directly, it throws an exception
so you can catch it. Potentially useful in downstream applications for
testing the environment configuration.
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

Successfully merging this pull request may close these issues.

2 participants