From 48f20291adf6d05a6027a1f2f27041383722ee47 Mon Sep 17 00:00:00 2001 From: Hendrik Muhs Date: Fri, 15 Mar 2024 17:53:12 +0100 Subject: [PATCH] fix candidate string for non-ascii --- .../dictionary/matching/fuzzy_multiword_completion_matching.h | 2 +- keyvi/include/keyvi/stringdistance/needleman_wunsch.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/keyvi/include/keyvi/dictionary/matching/fuzzy_multiword_completion_matching.h b/keyvi/include/keyvi/dictionary/matching/fuzzy_multiword_completion_matching.h index 6d963a3b1..a061e332f 100644 --- a/keyvi/include/keyvi/dictionary/matching/fuzzy_multiword_completion_matching.h +++ b/keyvi/include/keyvi/dictionary/matching/fuzzy_multiword_completion_matching.h @@ -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()); diff --git a/keyvi/include/keyvi/stringdistance/needleman_wunsch.h b/keyvi/include/keyvi/stringdistance/needleman_wunsch.h index 593a6f6d0..dde0fcab5 100644 --- a/keyvi/include/keyvi/stringdistance/needleman_wunsch.h +++ b/keyvi/include/keyvi/stringdistance/needleman_wunsch.h @@ -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 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());