chrono-node 2.7.2 → 2.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/locales/uk/parsers/AbstractParserWithWordBoundaryChecking.d.ts +11 -0
- package/dist/cjs/locales/uk/parsers/AbstractParserWithWordBoundaryChecking.js +24 -0
- package/dist/cjs/locales/uk/parsers/AbstractParserWithWordBoundaryChecking.js.map +1 -0
- package/dist/cjs/locales/uk/parsers/UKCasualDateParser.d.ts +3 -4
- package/dist/cjs/locales/uk/parsers/UKCasualDateParser.js +4 -9
- package/dist/cjs/locales/uk/parsers/UKCasualDateParser.js.map +1 -1
- package/dist/cjs/locales/uk/parsers/UKCasualTimeParser.d.ts +3 -4
- package/dist/cjs/locales/uk/parsers/UKCasualTimeParser.js +4 -10
- package/dist/cjs/locales/uk/parsers/UKCasualTimeParser.js.map +1 -1
- package/dist/cjs/locales/uk/parsers/UKMonthNameLittleEndianParser.d.ts +3 -4
- package/dist/cjs/locales/uk/parsers/UKMonthNameLittleEndianParser.js +14 -19
- package/dist/cjs/locales/uk/parsers/UKMonthNameLittleEndianParser.js.map +1 -1
- package/dist/cjs/locales/uk/parsers/UKMonthNameParser.d.ts +3 -4
- package/dist/cjs/locales/uk/parsers/UKMonthNameParser.js +10 -14
- package/dist/cjs/locales/uk/parsers/UKMonthNameParser.js.map +1 -1
- package/dist/cjs/locales/uk/parsers/UKRelativeDateFormatParser.d.ts +3 -4
- package/dist/cjs/locales/uk/parsers/UKRelativeDateFormatParser.js +5 -8
- package/dist/cjs/locales/uk/parsers/UKRelativeDateFormatParser.js.map +1 -1
- package/dist/cjs/locales/uk/parsers/UKTimeUnitAgoFormatParser.d.ts +3 -4
- package/dist/cjs/locales/uk/parsers/UKTimeUnitAgoFormatParser.js +4 -8
- package/dist/cjs/locales/uk/parsers/UKTimeUnitAgoFormatParser.js.map +1 -1
- package/dist/cjs/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.d.ts +3 -4
- package/dist/cjs/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js +4 -8
- package/dist/cjs/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js.map +1 -1
- package/dist/cjs/locales/uk/parsers/UKTimeUnitWithinFormatParser.js +3 -3
- package/dist/cjs/locales/uk/parsers/UKTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/cjs/locales/uk/parsers/UKWeekdayParser.d.ts +3 -4
- package/dist/cjs/locales/uk/parsers/UKWeekdayParser.js +10 -15
- package/dist/cjs/locales/uk/parsers/UKWeekdayParser.js.map +1 -1
- package/dist/esm/locales/uk/parsers/AbstractParserWithWordBoundaryChecking.d.ts +11 -0
- package/dist/esm/locales/uk/parsers/AbstractParserWithWordBoundaryChecking.js +19 -0
- package/dist/esm/locales/uk/parsers/AbstractParserWithWordBoundaryChecking.js.map +1 -0
- package/dist/esm/locales/uk/parsers/UKCasualDateParser.d.ts +3 -4
- package/dist/esm/locales/uk/parsers/UKCasualDateParser.js +4 -9
- package/dist/esm/locales/uk/parsers/UKCasualDateParser.js.map +1 -1
- package/dist/esm/locales/uk/parsers/UKCasualTimeParser.d.ts +3 -4
- package/dist/esm/locales/uk/parsers/UKCasualTimeParser.js +4 -10
- package/dist/esm/locales/uk/parsers/UKCasualTimeParser.js.map +1 -1
- package/dist/esm/locales/uk/parsers/UKMonthNameLittleEndianParser.d.ts +3 -4
- package/dist/esm/locales/uk/parsers/UKMonthNameLittleEndianParser.js +15 -20
- package/dist/esm/locales/uk/parsers/UKMonthNameLittleEndianParser.js.map +1 -1
- package/dist/esm/locales/uk/parsers/UKMonthNameParser.d.ts +3 -4
- package/dist/esm/locales/uk/parsers/UKMonthNameParser.js +11 -15
- package/dist/esm/locales/uk/parsers/UKMonthNameParser.js.map +1 -1
- package/dist/esm/locales/uk/parsers/UKRelativeDateFormatParser.d.ts +3 -4
- package/dist/esm/locales/uk/parsers/UKRelativeDateFormatParser.js +6 -9
- package/dist/esm/locales/uk/parsers/UKRelativeDateFormatParser.js.map +1 -1
- package/dist/esm/locales/uk/parsers/UKTimeUnitAgoFormatParser.d.ts +3 -4
- package/dist/esm/locales/uk/parsers/UKTimeUnitAgoFormatParser.js +5 -9
- package/dist/esm/locales/uk/parsers/UKTimeUnitAgoFormatParser.js.map +1 -1
- package/dist/esm/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.d.ts +3 -4
- package/dist/esm/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js +5 -9
- package/dist/esm/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.js.map +1 -1
- package/dist/esm/locales/uk/parsers/UKTimeUnitWithinFormatParser.js +3 -3
- package/dist/esm/locales/uk/parsers/UKTimeUnitWithinFormatParser.js.map +1 -1
- package/dist/esm/locales/uk/parsers/UKWeekdayParser.d.ts +3 -4
- package/dist/esm/locales/uk/parsers/UKWeekdayParser.js +11 -16
- package/dist/esm/locales/uk/parsers/UKWeekdayParser.js.map +1 -1
- package/package.json +1 -1
- package/src/locales/uk/parsers/AbstractParserWithWordBoundaryChecking.ts +27 -0
- package/src/locales/uk/parsers/UKCasualDateParser.ts +4 -14
- package/src/locales/uk/parsers/UKCasualTimeParser.ts +4 -14
- package/src/locales/uk/parsers/UKMonthNameLittleEndianParser.ts +17 -26
- package/src/locales/uk/parsers/UKMonthNameParser.ts +13 -20
- package/src/locales/uk/parsers/UKRelativeDateFormatParser.ts +8 -16
- package/src/locales/uk/parsers/UKTimeUnitAgoFormatParser.ts +5 -11
- package/src/locales/uk/parsers/UKTimeUnitCasualRelativeFormatParser.ts +4 -13
- package/src/locales/uk/parsers/UKTimeUnitWithinFormatParser.ts +3 -7
- package/src/locales/uk/parsers/UKWeekdayParser.ts +13 -21
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TIME_UNIT_DICTIONARY } from "../constants";
|
|
2
2
|
import { ParsingContext } from "../../../chrono";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
4
|
import dayjs from "dayjs";
|
|
5
|
-
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
6
5
|
import { matchAnyPattern } from "../../../utils/pattern";
|
|
7
|
-
|
|
8
|
-
const PATTERN = new RegExp(
|
|
9
|
-
`(в минулому|у минулому|на минулому|минулого|на наступному|в наступному|у наступному|наступного|на цьому|в цьому|у цьому|цього)\\s*(${matchAnyPattern(
|
|
10
|
-
TIME_UNIT_DICTIONARY
|
|
11
|
-
)})(?=\\s*)${REGEX_PARTS.rightBoundary}`,
|
|
12
|
-
REGEX_PARTS.flags
|
|
13
|
-
);
|
|
6
|
+
import { AbstractParserWithLeftRightBoundaryChecking } from "./AbstractParserWithWordBoundaryChecking";
|
|
14
7
|
|
|
15
8
|
const MODIFIER_WORD_GROUP = 1;
|
|
16
9
|
const RELATIVE_WORD_GROUP = 2;
|
|
17
10
|
|
|
18
|
-
export default class UKRelativeDateFormatParser extends
|
|
19
|
-
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return PATTERN;
|
|
11
|
+
export default class UKRelativeDateFormatParser extends AbstractParserWithLeftRightBoundaryChecking {
|
|
12
|
+
innerPatternString(context: ParsingContext): string {
|
|
13
|
+
return (
|
|
14
|
+
`(в минулому|у минулому|на минулому|минулого|на наступному|в наступному|у наступному|наступного|на цьому|в цьому|у цьому|цього)\\s*` +
|
|
15
|
+
`(${matchAnyPattern(TIME_UNIT_DICTIONARY)})(?=\\s*)`
|
|
16
|
+
);
|
|
25
17
|
}
|
|
26
18
|
|
|
27
19
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
|
-
import { parseTimeUnits,
|
|
2
|
+
import { parseTimeUnits, TIME_UNITS_PATTERN } from "../constants";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
|
-
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
4
|
import { reverseTimeUnits } from "../../../utils/timeunits";
|
|
5
|
+
import { AbstractParserWithLeftBoundaryChecking } from "./AbstractParserWithWordBoundaryChecking";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
patternLeftBoundary(): string {
|
|
11
|
-
return REGEX_PARTS.leftBoundary;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
innerPattern(): RegExp {
|
|
15
|
-
return PATTERN;
|
|
7
|
+
export default class UKTimeUnitAgoFormatParser extends AbstractParserWithLeftBoundaryChecking {
|
|
8
|
+
innerPatternString(context: ParsingContext): string {
|
|
9
|
+
return `(${TIME_UNITS_PATTERN})\\s{0,5}тому(?=(?:\\W|$))`;
|
|
16
10
|
}
|
|
17
11
|
|
|
18
12
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
import { TIME_UNITS_PATTERN, parseTimeUnits, REGEX_PARTS } from "../constants";
|
|
2
2
|
import { ParsingContext } from "../../../chrono";
|
|
3
3
|
import { ParsingComponents } from "../../../results";
|
|
4
|
-
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
4
|
import { reverseTimeUnits } from "../../../utils/timeunits";
|
|
5
|
+
import { AbstractParserWithLeftRightBoundaryChecking } from "./AbstractParserWithWordBoundaryChecking";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
export default class UKTimeUnitCasualRelativeFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
13
|
-
patternLeftBoundary(): string {
|
|
14
|
-
return REGEX_PARTS.leftBoundary;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
innerPattern(): RegExp {
|
|
18
|
-
return PATTERN;
|
|
7
|
+
export default class UKTimeUnitCasualRelativeFormatParser extends AbstractParserWithLeftRightBoundaryChecking {
|
|
8
|
+
innerPatternString(context: ParsingContext): string {
|
|
9
|
+
return `(ці|останні|минулі|майбутні|наступні|після|через|\\+|-)\\s*(${TIME_UNITS_PATTERN})`;
|
|
19
10
|
}
|
|
20
11
|
|
|
21
12
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
@@ -4,12 +4,6 @@ import { ParsingComponents } from "../../../results";
|
|
|
4
4
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
5
5
|
|
|
6
6
|
const PATTERN = `(?:(?:приблизно|орієнтовно)\\s*(?:~\\s*)?)?(${TIME_UNITS_PATTERN})${REGEX_PARTS.rightBoundary}`;
|
|
7
|
-
const PATTERN_WITH_PREFIX = new RegExp(
|
|
8
|
-
`(?:протягом|на протязі|протягом|упродовж|впродовж)\\s*${PATTERN}`,
|
|
9
|
-
REGEX_PARTS.flags
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
const PATTERN_WITHOUT_PREFIX = new RegExp(PATTERN, "i");
|
|
13
7
|
|
|
14
8
|
export default class UKTimeUnitWithinFormatParser extends AbstractParserWithWordBoundaryChecking {
|
|
15
9
|
patternLeftBoundary(): string {
|
|
@@ -17,7 +11,9 @@ export default class UKTimeUnitWithinFormatParser extends AbstractParserWithWord
|
|
|
17
11
|
}
|
|
18
12
|
|
|
19
13
|
innerPattern(context: ParsingContext): RegExp {
|
|
20
|
-
return context.option.forwardDate
|
|
14
|
+
return context.option.forwardDate
|
|
15
|
+
? new RegExp(PATTERN, "i")
|
|
16
|
+
: new RegExp(`(?:протягом|на протязі|протягом|упродовж|впродовж)\\s*${PATTERN}`, REGEX_PARTS.flags);
|
|
21
17
|
}
|
|
22
18
|
|
|
23
19
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|
|
@@ -1,34 +1,26 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
2
|
import { ParsingComponents } from "../../../results";
|
|
3
3
|
// TODO: ADD REGEX_PARTS below
|
|
4
|
-
import {
|
|
4
|
+
import { WEEKDAY_DICTIONARY } from "../constants";
|
|
5
5
|
import { matchAnyPattern } from "../../../utils/pattern";
|
|
6
|
-
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
7
6
|
import { createParsingComponentsAtWeekday } from "../../../common/calculation/weekdays";
|
|
8
|
-
|
|
9
|
-
const PATTERN = new RegExp(
|
|
10
|
-
`(?:(?:,|\\(|()\\s*)?` +
|
|
11
|
-
`(?:в\\s*?)?` +
|
|
12
|
-
`(?:у\\s*?)?` +
|
|
13
|
-
`(?:(цей|минулого|минулий|попередній|попереднього|наступного|наступний|наступному)\\s*)?` +
|
|
14
|
-
`(${matchAnyPattern(WEEKDAY_DICTIONARY)})` +
|
|
15
|
-
`(?:\\s*(?:,|\\)|)))?` +
|
|
16
|
-
`(?:\\s*(на|у|в)\\s*(цьому|минулому|наступному)\\s*тижні)?` +
|
|
17
|
-
`${REGEX_PARTS.rightBoundary}`,
|
|
18
|
-
REGEX_PARTS.flags
|
|
19
|
-
);
|
|
7
|
+
import { AbstractParserWithLeftRightBoundaryChecking } from "./AbstractParserWithWordBoundaryChecking";
|
|
20
8
|
|
|
21
9
|
const PREFIX_GROUP = 1;
|
|
22
10
|
const WEEKDAY_GROUP = 2;
|
|
23
11
|
const POSTFIX_GROUP = 3;
|
|
24
12
|
|
|
25
|
-
export default class UKWeekdayParser extends
|
|
26
|
-
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
export default class UKWeekdayParser extends AbstractParserWithLeftRightBoundaryChecking {
|
|
14
|
+
innerPatternString(context: ParsingContext): string {
|
|
15
|
+
return (
|
|
16
|
+
`(?:(?:,|\\(|()\\s*)?` +
|
|
17
|
+
`(?:в\\s*?)?` +
|
|
18
|
+
`(?:у\\s*?)?` +
|
|
19
|
+
`(?:(цей|минулого|минулий|попередній|попереднього|наступного|наступний|наступному)\\s*)?` +
|
|
20
|
+
`(${matchAnyPattern(WEEKDAY_DICTIONARY)})` +
|
|
21
|
+
`(?:\\s*(?:,|\\)|)))?` +
|
|
22
|
+
`(?:\\s*(на|у|в)\\s*(цьому|минулому|наступному)\\s*тижні)?`
|
|
23
|
+
);
|
|
32
24
|
}
|
|
33
25
|
|
|
34
26
|
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {
|