Skip to content

Commit

Permalink
[EN/ES NumberRange] Fixed compound disjoint range extraction (.NET on…
Browse files Browse the repository at this point in the history
…ly) (#2227)


Co-authored-by: LionbridgeCS2 <[email protected]>
  • Loading branch information
aitelint and LionbridgeCS2 authored Aug 25, 2020
1 parent afef01c commit a0d465a
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ public static class NumbersDefinitions
public const string LessRegexNoNumberSucceed = @"((less|lower|smaller|fewer)((?!\s+than)|\s+(than(?!(\s*\d+))))|(below|under)(?!(\s*\d+)))";
public const string EqualRegexNoNumberSucceed = @"(equal(s|ing)?((?!\s+(to|than))|(\s+(to|than)(?!(\s*\d+)))))";
public static readonly string OneNumberRangeMoreRegex1 = $@"({MoreOrEqual}|{MoreRegex})\s*(the\s+)?(?<number1>({NumberSplitMark}.)+)";
public static readonly string OneNumberRangeMoreRegex1LB = $@"(?<!no\s+){OneNumberRangeMoreRegex1}";
public static readonly string OneNumberRangeMoreRegex2 = $@"(?<number1>({NumberSplitMark}.)+)\s*{MoreOrEqualSuffix}";
public static readonly string OneNumberRangeMoreSeparateRegex = $@"({EqualRegex}\s+(?<number1>({NumberSplitMark}.)+)(\s+or\s+){MoreRegexNoNumberSucceed})|({MoreRegex}\s+(?<number1>({NumberSplitMark}.)+)(\s+or\s+){EqualRegexNoNumberSucceed})";
public static readonly string OneNumberRangeLessRegex1 = $@"({LessOrEqual}|{LessRegex})\s*(the\s+)?(?<number2>({NumberSplitMark}.)+)";
public static readonly string OneNumberRangeLessRegex1LB = $@"(?<!no\s+){OneNumberRangeLessRegex1}";
public static readonly string OneNumberRangeLessRegex2 = $@"(?<number2>({NumberSplitMark}.)+)\s*{LessOrEqualSuffix}";
public static readonly string OneNumberRangeLessSeparateRegex = $@"({EqualRegex}\s+(?<number1>({NumberSplitMark}.)+)(\s+or\s+){LessRegexNoNumberSucceed})|({LessRegex}\s+(?<number1>({NumberSplitMark}.)+)(\s+or\s+){EqualRegexNoNumberSucceed})";
public static readonly string OneNumberRangeEqualRegex = $@"{EqualRegex}\s*(the\s+)?(?<number1>({NumberSplitMark}.)+)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ public static class NumbersDefinitions
public const string LessRegexNoNumberSucceed = @"((meno(s|r(es)?)|inferior(es)?)((?!\s+(que|del?|a))|\s+((que|del?)(?!(\s*\d+))))|(por debajo)(?!(\s*\d+)))";
public const string EqualRegexNoNumberSucceed = @"((igual(es)?|equivalentes?|equivalen?)((?!\s+(al?|que|del?))|(\s+(al?|que|del?)(?!(\s*\d+)))))";
public static readonly string OneNumberRangeMoreRegex1 = $@"({MoreOrEqual}|{MoreRegex})\s*((el|las?|los)\s+)?(?<number1>({NumberSplitMark}.)+)";
public static readonly string OneNumberRangeMoreRegex1LB = $@"(?<!no\s+){OneNumberRangeMoreRegex1}";
public static readonly string OneNumberRangeMoreRegex2 = $@"(?<number1>({NumberSplitMark}.)+)\s*{MoreOrEqualSuffix}";
public static readonly string OneNumberRangeMoreSeparateRegex = $@"({EqualRegex}\s+(?<number1>({NumberSplitMark}.)+)(\s+o\s+){MoreRegexNoNumberSucceed})|({MoreRegex}\s+(?<number1>({NumberSplitMark}.)+)(\s+o\s+){EqualRegexNoNumberSucceed})";
public static readonly string OneNumberRangeLessRegex1 = $@"({LessOrEqual}|{LessRegex})\s*((el|las?|los)\s+)?(?<number2>({NumberSplitMark}.)+)";
public static readonly string OneNumberRangeLessRegex1LB = $@"(?<!no\s+){OneNumberRangeLessRegex1}";
public static readonly string OneNumberRangeLessRegex2 = $@"(?<number2>({NumberSplitMark}.)+)\s*{LessOrEqualSuffix}";
public static readonly string OneNumberRangeLessSeparateRegex = $@"({EqualRegex}\s+(?<number1>({NumberSplitMark}.)+)(\s+o\s+){LessRegexNoNumberSucceed})|({LessRegex}\s+(?<number1>({NumberSplitMark}.)+)(\s+o\s+){EqualRegexNoNumberSucceed})";
public static readonly string OneNumberRangeEqualRegex = $@"{EqualRegex}\s*((el|las?|los)\s+)?(?<number1>({NumberSplitMark}.)+)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public NumberRangeExtractor(INumberOptionsConfiguration config)
},
{
// more/greater/higher than ...
new Regex(NumbersDefinitions.OneNumberRangeMoreRegex1, RegexFlags),
new Regex(NumbersDefinitions.OneNumberRangeMoreRegex1LB, RegexFlags),
NumberRangeConstants.MORE
},
{
Expand All @@ -52,7 +52,7 @@ public NumberRangeExtractor(INumberOptionsConfiguration config)
},
{
// less/smaller/lower than ...
new Regex(NumbersDefinitions.OneNumberRangeLessRegex1, RegexFlags),
new Regex(NumbersDefinitions.OneNumberRangeLessRegex1LB, RegexFlags),
NumberRangeConstants.LESS
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public NumberRangeExtractor(INumberOptionsConfiguration config)
},
{
// más/mayor que ...
new Regex(NumbersDefinitions.OneNumberRangeMoreRegex1, RegexFlags),
new Regex(NumbersDefinitions.OneNumberRangeMoreRegex1LB, RegexFlags),
NumberRangeConstants.MORE
},
{
Expand All @@ -52,7 +52,7 @@ public NumberRangeExtractor(INumberOptionsConfiguration config)
},
{
// less/smaller/lower than ...
new Regex(NumbersDefinitions.OneNumberRangeLessRegex1, RegexFlags),
new Regex(NumbersDefinitions.OneNumberRangeLessRegex1LB, RegexFlags),
NumberRangeConstants.LESS
},
{
Expand Down
6 changes: 6 additions & 0 deletions Patterns/English/English-Numbers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ EqualRegexNoNumberSucceed: !simpleRegex
OneNumberRangeMoreRegex1: !nestedRegex
def: ({MoreOrEqual}|{MoreRegex})\s*(the\s+)?(?<number1>({NumberSplitMark}.)+)
references: [ MoreOrEqual, MoreRegex, NumberSplitMark ]
OneNumberRangeMoreRegex1LB: !nestedRegex
def: (?<!no\s+){OneNumberRangeMoreRegex1}
references: [ OneNumberRangeMoreRegex1 ]
OneNumberRangeMoreRegex2: !nestedRegex
def: (?<number1>({NumberSplitMark}.)+)\s*{MoreOrEqualSuffix}
references: [ MoreOrEqualSuffix, NumberSplitMark ]
Expand All @@ -191,6 +194,9 @@ OneNumberRangeMoreSeparateRegex: !nestedRegex
OneNumberRangeLessRegex1: !nestedRegex
def: ({LessOrEqual}|{LessRegex})\s*(the\s+)?(?<number2>({NumberSplitMark}.)+)
references: [ LessOrEqual, LessRegex, NumberSplitMark ]
OneNumberRangeLessRegex1LB: !nestedRegex
def: (?<!no\s+){OneNumberRangeLessRegex1}
references: [ OneNumberRangeLessRegex1 ]
OneNumberRangeLessRegex2: !nestedRegex
def: (?<number2>({NumberSplitMark}.)+)\s*{LessOrEqualSuffix}
references: [ LessOrEqualSuffix, NumberSplitMark ]
Expand Down
6 changes: 6 additions & 0 deletions Patterns/Spanish/Spanish-Numbers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ EqualRegexNoNumberSucceed: !simpleRegex
OneNumberRangeMoreRegex1: !nestedRegex
def: ({MoreOrEqual}|{MoreRegex})\s*((el|las?|los)\s+)?(?<number1>({NumberSplitMark}.)+)
references: [ MoreOrEqual, MoreRegex, NumberSplitMark ]
OneNumberRangeMoreRegex1LB: !nestedRegex
def: (?<!no\s+){OneNumberRangeMoreRegex1}
references: [ OneNumberRangeMoreRegex1 ]
OneNumberRangeMoreRegex2: !nestedRegex
def: (?<number1>({NumberSplitMark}.)+)\s*{MoreOrEqualSuffix}
references: [ MoreOrEqualSuffix, NumberSplitMark ]
Expand All @@ -190,6 +193,9 @@ OneNumberRangeMoreSeparateRegex: !nestedRegex
OneNumberRangeLessRegex1: !nestedRegex
def: ({LessOrEqual}|{LessRegex})\s*((el|las?|los)\s+)?(?<number2>({NumberSplitMark}.)+)
references: [ LessOrEqual, LessRegex, NumberSplitMark ]
OneNumberRangeLessRegex1LB: !nestedRegex
def: (?<!no\s+){OneNumberRangeLessRegex1}
references: [ OneNumberRangeLessRegex1 ]
OneNumberRangeLessRegex2: !nestedRegex
def: (?<number2>({NumberSplitMark}.)+)\s*{LessOrEqualSuffix}
references: [ LessOrEqualSuffix, NumberSplitMark ]
Expand Down
48 changes: 48 additions & 0 deletions Specs/Number/English/NumberRangeModel.json
Original file line number Diff line number Diff line change
Expand Up @@ -1275,5 +1275,53 @@
"End": 25
}
]
},
{
"Input": "x is no less than 194 and less than 12.",
"NotSupportedByDesign": "javascript, python, java",
"Results": [
{
"Text": "no less than 194",
"TypeName": "numberrange",
"Resolution": {
"value": "[194,)"
},
"Start": 5,
"End": 20
},
{
"Text": "less than 12",
"TypeName": "numberrange",
"Resolution": {
"value": "(,12)"
},
"Start": 26,
"End": 37
}
]
},
{
"Input": "x is no more than 12 and more than 194.",
"NotSupportedByDesign": "javascript, python, java",
"Results": [
{
"Text": "no more than 12",
"TypeName": "numberrange",
"Resolution": {
"value": "(,12]"
},
"Start": 5,
"End": 19
},
{
"Text": "more than 194",
"TypeName": "numberrange",
"Resolution": {
"value": "(194,)"
},
"Start": 25,
"End": 37
}
]
}
]
48 changes: 48 additions & 0 deletions Specs/Number/Spanish/NumberRangeModel.json
Original file line number Diff line number Diff line change
Expand Up @@ -1300,5 +1300,53 @@
}
}
]
},
{
"Input": "x es no menos de 194 y menos de 12.",
"NotSupportedByDesign": "javascript, python, java",
"Results": [
{
"Text": "no menos de 194",
"TypeName": "numberrange",
"Resolution": {
"value": "[194,)"
},
"Start": 5,
"End": 19
},
{
"Text": "menos de 12",
"TypeName": "numberrange",
"Resolution": {
"value": "(,12)"
},
"Start": 23,
"End": 33
}
]
},
{
"Input": "x es no más de 12 y más de 194.",
"NotSupportedByDesign": "javascript, python, java",
"Results": [
{
"Text": "no más de 12",
"TypeName": "numberrange",
"Resolution": {
"value": "(,12]"
},
"Start": 5,
"End": 16
},
{
"Text": "más de 194",
"TypeName": "numberrange",
"Resolution": {
"value": "(194,)"
},
"Start": 20,
"End": 29
}
]
}
]

0 comments on commit a0d465a

Please sign in to comment.