Skip to content

Commit

Permalink
Improve correction of monosyllabic candidates
Browse files Browse the repository at this point in the history
  • Loading branch information
graphemecluster committed Nov 15, 2024
1 parent 3bee2a6 commit c77d537
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/rime/algo/syllabifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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()) {
Expand Down
4 changes: 3 additions & 1 deletion src/rime/dict/prism.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit c77d537

Please sign in to comment.