Skip to content

Commit

Permalink
Fix bugs introduced in commit 3c9c06e:
Browse files Browse the repository at this point in the history
account for final weight in path weight;
normalize path probabilities.
  • Loading branch information
mjansche committed Apr 13, 2016
1 parent ef3ddf9 commit f9211a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions festus/runtime/fst-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ void DeterminizeConvertWeight(
// path in the FST.
template <class F>
std::vector<std::pair<string, float>> ShortestPathsToVector(
const F &paths_fst,
typename F::Arc::Weight total_weight = F::Arc::Weight::One()) {
const F &paths_fst) {
typedef typename F::Arc Arc;
typedef typename F::StateId StateId;
typedef typename F::Weight Weight;
Expand Down Expand Up @@ -329,6 +328,7 @@ std::vector<std::pair<string, float>> ShortestPathsToVector(
CHECK((iter.Next(), iter.Done()));
}
CHECK(fst::ArcIterator<fst::VectorFst<Arc>>(paths_fst, state).Done());
weight = Times(weight, paths_fst.Final(state));
paths.emplace_back(std::move(str), weight.Value());
}
return paths;
Expand Down
4 changes: 2 additions & 2 deletions festus/runtime/g2p.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ bool G2P<Arc>::Pronounce(const string &spelling,
}

VLOG(2) << "8. Convert shortest paths to pronunciations.";
result->pronunciations = ShortestPathsToVector(paths, total_weight.Value());
result->pronunciations = ShortestPathsToVector(paths);
for (auto &pron : result->pronunciations) {
pron.second = std::exp(-pron.second);
pron.second = std::exp(total_weight.Value() - pron.second);
}
result->error.clear();
return true;
Expand Down

0 comments on commit f9211a7

Please sign in to comment.