Skip to content

Commit 77fbd83

Browse files
author
Wanasit Tanakitrungruang
committedMay 30, 2021
Fix: ending with a/p is not necessary time expression
1 parent dde6103 commit 77fbd83

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
 

‎src/common/parsers/AbstractTimeExpressionParser.ts

+5
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,11 @@ export abstract class AbstractTimeExpressionParser implements Parser {
310310
return null;
311311
}
312312

313+
// Instead of "am/pm", it ends with "a" or "p" (e.g "1a", "123p"), this seems unlikely
314+
if (result.text.match(/\d[apAP]$/)) {
315+
return null;
316+
}
317+
313318
// If it ends only with numbers or dots
314319
const endingWithNumbers = result.text.match(/[^\d:.](\d[\d.]+)$/);
315320
if (endingWithNumbers) {

‎test/en/negative_cases.test.ts

+11
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ test("Test - Skip random non-date patterns", function () {
2323
testUnexpectedResult(chrono, "at 6.5 kilograms");
2424
});
2525

26+
test("Test - URLs % encoded", function () {
27+
testUnexpectedResult(chrono, "%e7%b7%8a");
28+
29+
testUnexpectedResult(
30+
chrono,
31+
"https://tenor.com/view/%e3%83%89%e3%82%ad%e3%83%89%e3%82%ad-" +
32+
"%e7%b7%8a%e5%bc%b5-%e5%a5%bd%e3%81%8d-%e3%83%8f%e3%83%bc%e3%83%88" +
33+
"-%e5%8f%af%e6%84%9b%e3%81%84-gif-15876325"
34+
);
35+
});
36+
2637
test("Test - Skip hyphenated numbers pattern", () => {
2738
testUnexpectedResult(chrono, "1-2");
2839

0 commit comments

Comments
 (0)
Please sign in to comment.