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

Fix handling of node-format when output-format-type is set #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mecab/src/tagger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ const MeCab::Option long_options[] = {
"output marginal probability (default false)" },
{ "max-grouping-size", 'M', "24",
"INT", "maximum grouping size for unknown words (default 24)" },
{ "node-format", 'F', "%m\\t%H\\n", "STR",
{ "node-format", 'F', "", "STR",
"use STR as the user-defined node format" },
{ "unk-format", 'U', "%m\\t%H\\n", "STR",
{ "unk-format", 'U', "", "STR",
"use STR as the user-defined unknown node format" },
{ "bos-format", 'B', "", "STR",
"use STR as the user-defined beginning-of-sentence format" },
Expand Down
10 changes: 6 additions & 4 deletions mecab/src/writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ void Writer::close() {
}

bool Writer::open(const Param &param) {
const std::string ostyle = param.get<std::string>("output-format-type");
const std::string node_format_option = param.get<std::string>("node-format");
const std::string ostyle = node_format_option.empty() ? param.get<std::string>("output-format-type") : "";
write_ = &Writer::writeLattice;

if (ostyle == "wakati") {
Expand Down Expand Up @@ -77,7 +78,8 @@ bool Writer::open(const Param &param) {
if (node_format != node_format2 || bos_format != bos_format2 ||
eos_format != eos_format2 || unk_format != unk_format2) {
write_ = &Writer::writeUser;
if (node_format != node_format2) {

if (!node_format2.empty() && node_format != node_format2) {
node_format = node_format2;
}
if (bos_format != bos_format2) {
Expand All @@ -86,9 +88,9 @@ bool Writer::open(const Param &param) {
if (eos_format != eos_format2) {
eos_format = eos_format2;
}
if (unk_format != unk_format2) {
if (!unk_format2.empty() && unk_format != unk_format2) {
unk_format = unk_format2;
} else if (node_format != node_format2) {
} else if (!node_format2.empty() && node_format != node_format2) {
unk_format = node_format2;
} else {
unk_format = node_format;
Expand Down