Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
shell: bash

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Install dependencies (Ubuntu)
if: startsWith(matrix.os, 'ubuntu-')
Expand Down
2 changes: 1 addition & 1 deletion src/core/analysis/numeric_creator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ size_t NumericUnkMaker::checkPeriod(const CodepointStorage &codepoints,
if (pos == 0) return 0;
if (!codepoints[posPeriod].hasClass(PeriodClass)) return 0;
if (!codepoints[posPeriod - 1].hasClass(charClass_)) return 0;
if (pos + 1 < codepoints.size() &&
if (posPeriod + 1 < codepoints.size() &&
codepoints[posPeriod + 1].hasClass(charClass_))
return 1;
return 0;
Expand Down
21 changes: 21 additions & 0 deletions src/core/analysis/numeric_creator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,27 @@ TEST_CASE("do not make numeric unk nodes ends with period") {
CHECK(env.numNodeSeeds() == 1);
}

// Regression for ku-nlp/jumanpp#157: trailing digit+period caused a read
// past the end of the codepoint vector during the second spawnNodes pass
// (start > 0), because checkPeriod bounded the lookahead against `pos`
// instead of the absolute position `start + pos`.
TEST_CASE("multi-digit number followed by trailing period does not crash") {
NumericTestEnv env{"x,l1\nほげ,l2\n"};
env.analyze("10.");
CHECK(env.contains("10", 0, "l1"));
CHECK(env.contains("0", 1, "l1"));
CHECK(!env.contains("10.", 0, "l1"));
CHECK(!env.contains("0.", 1, "l1"));
CHECK(env.numNodeSeeds() == 2);
}

TEST_CASE("digit+period preceded by non-numeric context does not crash") {
NumericTestEnv env{"x,l1\nほげ,l2\n"};
env.analyze("ほげ4.");
CHECK(env.contains("4", 2, "l1"));
CHECK(!env.contains("4.", 2, "l1"));
}

TEST_CASE("do not make numeric unk nodes starts with period") {
NumericTestEnv env{"x,l1\nほげ,l2\n"};
env.analyze(".4");
Expand Down