Skip to content

Commit

Permalink
fix candidate string for non-ascii
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikmuhs committed Mar 15, 2024
1 parent bca0b3b commit 48f2029
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class FuzzyMultiwordCompletionMatching final {

if (traverser_ptr_->IsFinalState()) {
std::string match_str = multiword_boundary_ > 0
? distance_metric_->GetCandidate().substr(prefix_length_ + multiword_boundary_)
? distance_metric_->GetCandidate(prefix_length_ + multiword_boundary_)
: distance_metric_->GetCandidate();

TRACE("found final state at depth %d %s", prefix_length_ + traverser_ptr_->GetDepth(), match_str.c_str());
Expand Down
4 changes: 2 additions & 2 deletions keyvi/include/keyvi/stringdistance/needleman_wunsch.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ class NeedlemanWunsch final {

int32_t GetScore() const { return distance_matrix_.Get(latest_calculated_row_, distance_matrix_.Columns() - 1); }

std::string GetCandidate() {
std::string GetCandidate(size_t pos = 0) {
std::vector<unsigned char> utf8result;
utf8::utf32to8(compare_sequence_.begin(), compare_sequence_.begin() + last_put_position_ + 1,
utf8::utf32to8(compare_sequence_.begin() + pos, compare_sequence_.begin() + last_put_position_ + 1,
back_inserter(utf8result));

return std::string(utf8result.begin(), utf8result.end());
Expand Down

0 comments on commit 48f2029

Please sign in to comment.