diff --git a/Source/Engine/Gramambular/Grid.h b/Source/Engine/Gramambular/Grid.h index ee5a3bf3..e13c8eab 100644 --- a/Source/Engine/Gramambular/Grid.h +++ b/Source/Engine/Gramambular/Grid.h @@ -182,6 +182,10 @@ namespace Formosa { vector nodes = nodesCrossingOrEndingAt(location); for (auto nodeAnchor : nodes) { auto candidates = nodeAnchor.node->candidates(); + + // Reset the candidate-fixed state of every node at the location. + const_cast(nodeAnchor.node)->resetCandidate(); + for (size_t i = 0, c = candidates.size(); i < c; ++i) { if (candidates[i].value == value) { const_cast(nodeAnchor.node)->selectCandidateAtIndex(i); diff --git a/Source/Engine/Gramambular/Node.h b/Source/Engine/Gramambular/Node.h index d4b7b432..89a74813 100644 --- a/Source/Engine/Gramambular/Node.h +++ b/Source/Engine/Gramambular/Node.h @@ -46,6 +46,7 @@ namespace Formosa { bool isCandidateFixed() const; const vector& candidates() const; void selectCandidateAtIndex(size_t inIndex = 0, bool inFix = true); + void resetCandidate(); const string& key() const; double score() const; @@ -164,7 +165,16 @@ namespace Formosa { m_candidateFixed = inFix; m_score = 99; - } + } + + inline void Node::resetCandidate() + { + m_selectedUnigramIndex = 0; + m_candidateFixed = 0; + if (m_unigrams.size()) { + m_score = m_unigrams[0].score; + } + } inline const string& Node::key() const {