Prevents the override model to remember symbols with scode -8 or lower.
This commit is contained in:
parent
4d94bb0cd2
commit
b5d9ce60bf
|
@ -51,6 +51,7 @@ namespace Formosa {
|
||||||
|
|
||||||
const string& key() const;
|
const string& key() const;
|
||||||
double score() const;
|
double score() const;
|
||||||
|
double scoreForCandidate(string &candidate) const;
|
||||||
const KeyValuePair currentKeyValue() const;
|
const KeyValuePair currentKeyValue() const;
|
||||||
double highestUnigramScore() const;
|
double highestUnigramScore() const;
|
||||||
|
|
||||||
|
@ -198,6 +199,16 @@ namespace Formosa {
|
||||||
return m_score;
|
return m_score;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline double Node::scoreForCandidate(string &candidate) const
|
||||||
|
{
|
||||||
|
for (auto unigram : m_unigrams) {
|
||||||
|
if (unigram.keyValue.value == candidate) {
|
||||||
|
return unigram.score;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
inline double Node::highestUnigramScore() const {
|
inline double Node::highestUnigramScore() const {
|
||||||
if (m_unigrams.empty()) {
|
if (m_unigrams.empty()) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
|
|
@ -202,7 +202,17 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot
|
||||||
// If the length of the readings and the characters do not match,
|
// 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
|
// it often means it is a special symbol and it should not be stored
|
||||||
// in the user override model.
|
// 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 <= -8) {
|
||||||
|
addToOverrideModel = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (addToOverrideModel) {
|
||||||
_userOverrideModel->observe(_walkedNodes, cursorIndex, stringValue, [[NSDate date] timeIntervalSince1970]);
|
_userOverrideModel->observe(_walkedNodes, cursorIndex, stringValue, [[NSDate date] timeIntervalSince1970]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue