From e506efbb4e0b5d508211024cdad60cb08d584d0f Mon Sep 17 00:00:00 2001 From: bab2min Date: Thu, 2 May 2024 01:30:21 +0900 Subject: [PATCH] fixed bab2min/kiwipiepy#168 --- src/Kiwi.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Kiwi.cpp b/src/Kiwi.cpp index 530bcd23..f3bde52d 100644 --- a/src/Kiwi.cpp +++ b/src/Kiwi.cpp @@ -898,8 +898,11 @@ namespace kiwi { ret.clear(); auto* cur = first; - for (size_t i = 0; i < nodes.size() && cur != last; ++i) + for (size_t i = 0; i < nodes.size(); ++i) { + while (cur != last && nodes[i].startPos >= cur->end) ++cur; + if (cur == last) break; + if (cur->begin <= nodes[i].startPos && nodes[i].endPos <= cur->end) { ret.emplace_back(cur - first); @@ -907,7 +910,6 @@ namespace kiwi else { ret.emplace_back(-1); - if (nodes[i].startPos >= cur->end) ++cur; } } ret.resize(nodes.size(), -1);