Skip to content

Commit

Permalink
telex: fix word exception lookup cases
Browse files Browse the repository at this point in the history
  • Loading branch information
dinhngtu committed Jan 14, 2024
1 parent 8c15a27 commit 5646966
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Telex/TelexEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,16 @@ TelexStates TelexEngine::Commit() {
return _state;
}

if (_state == TelexStates::Valid) {
if (_config.optimize_multilang >= 1 && word_exceptions_en.find(_keyBuffer) != word_exceptions_en.end()) {
if (_state == TelexStates::Valid && _config.optimize_multilang >= 1) {
auto wordBuffer = _keyBuffer;
for (auto& c : wordBuffer) {
c = ToLower(c);
}
if (word_exceptions_en.find(wordBuffer) != word_exceptions_en.end()) {
_state = TelexStates::CommittedInvalid;
return _state;
}
if (_config.optimize_multilang >= 2 && word_exceptions_en_2.find(_keyBuffer) != word_exceptions_en_2.end()) {
if (_config.optimize_multilang >= 2 && word_exceptions_en_2.find(wordBuffer) != word_exceptions_en_2.end()) {
_state = TelexStates::CommittedInvalid;
return _state;
}
Expand Down
15 changes: 15 additions & 0 deletions VietTypeUnitTests/TestTelex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ TEST_CLASS (TestTelex) {
}

// test multilang optimizations

TEST_METHOD (TestMultilangVirus) {
auto config1 = config;
config1.optimize_multilang = 1;
Expand All @@ -838,6 +839,20 @@ TEST_CLASS (TestTelex) {
AssertTelexStatesEqual(TelexStates::Invalid, FeedWord(e, L"defe"));
}

TEST_METHOD (TestMultilangVirusUpper) {
auto config1 = config;
config1.optimize_multilang = 1;
TelexEngine e(config1);
VietType::UnitTests::TestInvalidWord(e, L"VIRUS", L"VIRUS");
}

TEST_METHOD (TestMultilangDenseUpper) {
auto config1 = config;
config1.optimize_multilang = 2;
TelexEngine e(config1);
VietType::UnitTests::TestInvalidWord(e, L"DENSE", L"DENSE");
}

// test doublekey backspace

TEST_METHOD (TestBackspaceMooo) {
Expand Down

0 comments on commit 5646966

Please sign in to comment.