Zonble: KeyHandler // Don't let UOM remember symbols.
- This feature is okay to be enabled since we have introduced SymbolLM. Co-Authored-By: Weizhong Yang a.k.a zonble <zonble@gmail.com>
This commit is contained in:
parent
81f5e0dec1
commit
3e9725cafb
|
@ -208,7 +208,17 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
|||
// If the length of the readings and the characters do not match,
|
||||
// it often means it is a special symbol and it should not be stored
|
||||
// in the user override model.
|
||||
if (selectedNode.spanningLength == [value count]) {
|
||||
BOOL addToOverrideModel = YES;
|
||||
if (selectedNode.spanningLength != [value count]) {
|
||||
addToOverrideModel = NO;
|
||||
}
|
||||
if (addToOverrideModel) {
|
||||
double score = selectedNode.node->scoreForCandidate(stringValue);
|
||||
if (score <= -12) { // 威注音的 SymbolLM 的 Score 是 -12。
|
||||
addToOverrideModel = NO;
|
||||
}
|
||||
}
|
||||
if (addToOverrideModel) {
|
||||
_userOverrideModel->observe(_walkedNodes, cursorIndex, stringValue, [[NSDate date] timeIntervalSince1970]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,15 +184,15 @@ inline const std::string& Node::key() const { return m_key; }
|
|||
|
||||
inline double Node::score() const { return m_score; }
|
||||
|
||||
// Prevents the override model to remember symbols with scode -X or lower.
|
||||
//inline double Node::scoreForCandidate(const std::string& candidate) const {
|
||||
// for (auto unigram : m_unigrams) {
|
||||
// if (unigram.keyValue.value == candidate) {
|
||||
// return unigram.score;
|
||||
// }
|
||||
// }
|
||||
// return 0.0;
|
||||
//}
|
||||
|
||||
inline double Node::scoreForCandidate(const std::string& candidate) const {
|
||||
for (auto unigram : m_unigrams) {
|
||||
if (unigram.keyValue.value == candidate) {
|
||||
return unigram.score;
|
||||
}
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
inline double Node::highestUnigramScore() const {
|
||||
if (m_unigrams.empty()) {
|
||||
|
|
Loading…
Reference in New Issue