Skip to content

Commit

Permalink
Fix: (en) The second could be ordinal number or timeunit
Browse files Browse the repository at this point in the history
  • Loading branch information
Wanasit Tanakitrungruang committed Jan 25, 2025
1 parent 257722f commit 6d8d672
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/locales/en/refiners/ENUnlikelyFormatFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ export default class ENUnlikelyFormatFilter extends Filter {
}
}

// In English, "the second" could refer to the ordinal number or timeunit.
if (text.toLowerCase().endsWith("the second")) {
const textAfter = context.text.substring(result.index + result.text.length).trim();
if (textAfter.length > 0) {
context.debug(() => {
console.log(`Removing unlikely result: ${result}`);
});
}
return false;
}

return true;
}
}
2 changes: 2 additions & 0 deletions test/en/en_casual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ test("Test - Random negative text", () => {

testUnexpectedResult(chrono, "I may by here. May the force be with you. Theresa may become PM soon.");

testUnexpectedResult(chrono, "XXX is set to be released in the second half of 2025");

testUnexpectedResult(chrono.casual, "do I have the money");

testUnexpectedResult(chrono.en.GB, "do I have the money");
Expand Down
1 change: 1 addition & 0 deletions test/en/en_time_units_within.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,5 @@ test("Test - Forward date option", () => {
test("Test - Negative cases", () => {
testUnexpectedResult(chrono, "in am");
testUnexpectedResult(chrono, "in them");
testUnexpectedResult(chrono, "the second half");
});

0 comments on commit 6d8d672

Please sign in to comment.