Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
bab2min committed Aug 20, 2023
1 parent 2cddd46 commit 2f845c6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/kiwi/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ namespace kiwi
{
return !operator==(o);
}

uint32_t endPos() const { return position + length; }
};

struct BasicToken
Expand Down
17 changes: 17 additions & 0 deletions src/Kiwi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,15 +482,32 @@ namespace kiwi
auto& t = tokens[i];
if ((i >= nestedEnd) && sp.next(t, nlPos, nestedSentEnd && i == nestedSentEnd))
{
bool includePrevToken = i > 1 &&
(tokens[i - 1].tag == POSTag::so
|| tokens[i - 1].tag == POSTag::sw
|| tokens[i - 1].tag == POSTag::sp
|| tokens[i - 1].tag == POSTag::se)
&& tokens[i - 1].endPos() == tokens[i].position
&& tokens[i - 1].position > tokens[i - 2].endPos();
if (nestedSentEnd)
{
subSentPos++;
accumSubSent++;
if (includePrevToken)
{
tokens[i - 1].subSentPosition = subSentPos;
}
}
else
{
sentPos++;
accumSubSent = 1;
if (includePrevToken)
{
tokens[i - 1].sentPosition = sentPos;
tokens[i - 1].wordPosition = 0;
accumWordPos = 0;
}
}
}

Expand Down

0 comments on commit 2f845c6

Please sign in to comment.