diff --git a/src/rime/algo/syllabifier.cc b/src/rime/algo/syllabifier.cc index 75437f6332..9fb9b7a689 100644 --- a/src/rime/algo/syllabifier.cc +++ b/src/rime/algo/syllabifier.cc @@ -67,7 +67,7 @@ int Syllabifier::BuildSyllableGraph(const string& input, for (auto accessor = prism.QuerySpelling(m.first); !accessor.exhausted(); accessor.Next()) { if (accessor.properties().type == kNormalSpelling) { - matches.push_back({m.first, m.second.length}); + matches.push_back({m.first, m.second.length, m.second.distance}); break; } } @@ -110,7 +110,7 @@ int Syllabifier::BuildSyllableGraph(const string& input, continue; } props.is_correction = true; - props.credibility = kCorrectionCredibility; + props.credibility = kCorrectionCredibility * m.distance; } auto it = spellings.find(syllable_id); if (it == spellings.end()) { diff --git a/src/rime/dict/prism.h b/src/rime/dict/prism.h index 7839b5f58d..ac18f83f3b 100644 --- a/src/rime/dict/prism.h +++ b/src/rime/dict/prism.h @@ -65,7 +65,9 @@ class Script; class Prism : public MappedFile { public: - using Match = Darts::DoubleArray::result_pair_type; + struct Match : Darts::DoubleArray::result_pair_type { + size_t distance = 0; + }; RIME_API explicit Prism(const path& file_path);