Skip to content

Commit

Permalink
fix log json missing unigram bigram info if output sbs not set
Browse files Browse the repository at this point in the history
  • Loading branch information
nishchalb committed Apr 18, 2024
1 parent 374b2c5 commit 2c76656
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/fstalign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ void HandleWer(FstLoader& refLoader, FstLoader& hypLoader, SynonymEngine &engine
}
}

JsonLogUnigramBigramStats(topAlignment);
if (!output_sbs.empty()) {
logger->info("output_sbs = {}", output_sbs);
WriteSbs(topAlignment, stitches, output_sbs);
Expand Down
6 changes: 4 additions & 2 deletions src/wer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,10 @@ void WriteSbs(wer_alignment &topAlignment, const vector<Stitching>& stitches, st
myfile << fmt::format("{0:>20}\t{1}", group.first, group.second) << endl;
}

myfile.close();
}

void JsonLogUnigramBigramStats(wer_alignment &topAlignment) {
for (const auto &a : topAlignment.unigram_stats) {
string word = a.first;
gram_error_counter u = a.second;
Expand All @@ -626,6 +630,4 @@ void WriteSbs(wer_alignment &topAlignment, const vector<Stitching>& stitches, st
jsonLogger::JsonLogger::getLogger().root["wer"]["bigrams"][word]["precision"] = u.precision;
jsonLogger::JsonLogger::getLogger().root["wer"]["bigrams"][word]["recall"] = u.recall;
}

myfile.close();
}
1 change: 1 addition & 0 deletions src/wer.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ typedef vector<pair<size_t, string>> ErrorGroups;

void AddErrorGroup(ErrorGroups &groups, size_t &line, string &ref, string &hyp);
void WriteSbs(wer_alignment &topAlignment, const vector<Stitching>& stitches, string sbs_filename);
void JsonLogUnigramBigramStats(wer_alignment &topAlignment);

0 comments on commit 2c76656

Please sign in to comment.