Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dict::Match() does not check for exact match #523

Closed
coin3x opened this issue Sep 13, 2020 · 1 comment
Closed

Dict::Match() does not check for exact match #523

coin3x opened this issue Sep 13, 2020 · 1 comment

Comments

@coin3x
Copy link

coin3x commented Sep 13, 2020

Broken since be2492c

Optional<const DictEntry*> MarisaDict::Match(const char* word,
size_t len) const {
const marisa::Trie& trie = *internal->marisa;
marisa::Agent agent;
agent.set_query(word, (std::min)(maxLength, len));

OpenCC/src/DartsDict.cpp

Lines 55 to 60 in 539e4e9

Optional<const DictEntry*> DartsDict::Match(const char* word,
size_t len) const {
Darts::DoubleArray& dict = *internal->doubleArray;
Darts::DoubleArray::result_pair_type result;
dict.exactMatchSearch(word, result, (std::min)(maxLength, len));

Example Dict:
爲 -> 為

maxLength: 3

std::string query("爲123");
dict->Match(query);

len: 6

Expected: Optional::Null
Actual: DictEntry 爲 -> 為

lotem added a commit to lotem/OpenCC that referenced this issue Dec 16, 2020
…act match

if query is longer than the longest word in dictionary.
@lotem lotem closed this as completed in f753bb5 Dec 20, 2020
@BYVoid
Copy link
Owner

BYVoid commented Feb 25, 2021

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants