Skip to content

Commit

Permalink
Merge pull request #67 from lukhnos/uom-fix
Browse files Browse the repository at this point in the history
Fix a bug in how UOM ignores punctuations
  • Loading branch information
zonble authored Jul 20, 2022
2 parents ae738d4 + 4c8a39c commit b2da409
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/Engine/UserOverrideModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,11 @@ static std::string FormObservationKey(std::vector<Formosa::Gramambular2::Reading
std::string anteriorStr;
if (head != end && !prevIsPunctuation) {
--head;
anteriorStr = CombineReadingValue((*head)->reading(), (*head)->currentUnigram().value());
if (IsPunctuation((*head))) {
anteriorStr = kEmptyNodeString;
} else {
anteriorStr = CombineReadingValue((*head)->reading(), (*head)->currentUnigram().value());
}
} else {
anteriorStr = kEmptyNodeString;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Engine/UserOverrideModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class UserOverrideModel {
UserOverrideModel(size_t capacity, double decayConstant);

struct Suggestion {
Suggestion() { }
Suggestion() = default;
Suggestion(std::string c, bool f)
: candidate(std::move(c))
, forceHighScoreOverride(f)
Expand All @@ -46,7 +46,7 @@ class UserOverrideModel {
std::string candidate;
bool forceHighScoreOverride = false;

bool empty()
[[nodiscard]] bool empty() const
{
return candidate.empty();
}
Expand Down Expand Up @@ -93,6 +93,6 @@ class UserOverrideModel {
std::map<std::string, std::list<KeyObservationPair>::iterator> m_lruMap;
};

}; // namespace McBopomofo
} // namespace McBopomofo

#endif

0 comments on commit b2da409

Please sign in to comment.