-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a parametric matching timeout to all Regex instances (#3045)
* adding parameterized regex timeout * removing net462 * adding the missing Swedish type * - using default when timeout is not assigned to * refactoring and cleaning up * more clean ups * - rebase from the master - adding net462 back
- Loading branch information
FARHAD SHAKERIN
authored
Mar 6, 2023
1 parent
48c71fd
commit 760e836
Showing
467 changed files
with
5,399 additions
and
6,524 deletions.
There are no files selected for viewing
43 changes: 10 additions & 33 deletions
43
...icrosoft.Recognizers.Text.Choice/Arabic/Extractors/ArabicBooleanExtractorConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,24 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
|
||
using Microsoft.Recognizers.Definitions.Arabic; | ||
using Microsoft.Recognizers.Text.Choice.Extractors; | ||
|
||
namespace Microsoft.Recognizers.Text.Choice.Arabic | ||
{ | ||
public class ArabicBooleanExtractorConfiguration : IBooleanExtractorConfiguration | ||
public class ArabicBooleanExtractorConfiguration : BaseBooleanExtractorConfiguration | ||
{ | ||
public static readonly Regex TrueRegex = | ||
new Regex(ChoiceDefinitions.TrueRegex, RegexOptions.Singleline | RegexOptions.RightToLeft); | ||
|
||
public static readonly Regex FalseRegex = | ||
new Regex(ChoiceDefinitions.FalseRegex, RegexOptions.Singleline | RegexOptions.RightToLeft); | ||
|
||
public static readonly Regex TokenRegex = | ||
new Regex(ChoiceDefinitions.TokenizerRegex, RegexOptions.Singleline | RegexOptions.RightToLeft); | ||
|
||
public static readonly IDictionary<Regex, string> MapRegexes = new Dictionary<Regex, string>() | ||
{ | ||
{ TrueRegex, Constants.SYS_BOOLEAN_TRUE }, | ||
{ FalseRegex, Constants.SYS_BOOLEAN_FALSE }, | ||
}; | ||
|
||
public ArabicBooleanExtractorConfiguration(bool onlyTopMatch = true) | ||
: base( | ||
trueRegex: ChoiceDefinitions.TrueRegex, | ||
falseRegex: ChoiceDefinitions.FalseRegex, | ||
tokenRegex: ChoiceDefinitions.TokenizerRegex, | ||
options: RegexOptions.Singleline | RegexOptions.RightToLeft, | ||
allowPartialMatch: false, | ||
maxDistance: 2, | ||
onlyTopMatch) | ||
{ | ||
this.OnlyTopMatch = onlyTopMatch; | ||
} | ||
|
||
Regex IBooleanExtractorConfiguration.TrueRegex => TrueRegex; | ||
|
||
Regex IBooleanExtractorConfiguration.FalseRegex => FalseRegex; | ||
|
||
IDictionary<Regex, string> IChoiceExtractorConfiguration.MapRegexes => MapRegexes; | ||
|
||
Regex IChoiceExtractorConfiguration.TokenRegex => TokenRegex; | ||
|
||
public bool AllowPartialMatch => false; | ||
|
||
public int MaxDistance => 2; | ||
|
||
public bool OnlyTopMatch { get; } | ||
} | ||
} |
43 changes: 10 additions & 33 deletions
43
...ft.Recognizers.Text.Choice/Bulgarian/Extractors/BulgarianBooleanExtractorConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,24 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
|
||
using Microsoft.Recognizers.Definitions.Bulgarian; | ||
using Microsoft.Recognizers.Text.Choice.Extractors; | ||
|
||
namespace Microsoft.Recognizers.Text.Choice.Bulgarian | ||
{ | ||
public class BulgarianBooleanExtractorConfiguration : IBooleanExtractorConfiguration | ||
public class BulgarianBooleanExtractorConfiguration : BaseBooleanExtractorConfiguration | ||
{ | ||
public static readonly Regex TrueRegex = | ||
new Regex(ChoiceDefinitions.TrueRegex, RegexOptions.Singleline); | ||
|
||
public static readonly Regex FalseRegex = | ||
new Regex(ChoiceDefinitions.FalseRegex, RegexOptions.Singleline); | ||
|
||
public static readonly Regex TokenRegex = | ||
new Regex(ChoiceDefinitions.TokenizerRegex, RegexOptions.Singleline); | ||
|
||
public static readonly IDictionary<Regex, string> MapRegexes = new Dictionary<Regex, string>() | ||
{ | ||
{ TrueRegex, Constants.SYS_BOOLEAN_TRUE }, | ||
{ FalseRegex, Constants.SYS_BOOLEAN_FALSE }, | ||
}; | ||
|
||
public BulgarianBooleanExtractorConfiguration(bool onlyTopMatch = true) | ||
: base( | ||
trueRegex: ChoiceDefinitions.TrueRegex, | ||
falseRegex: ChoiceDefinitions.FalseRegex, | ||
tokenRegex: ChoiceDefinitions.TokenizerRegex, | ||
options: RegexOptions.Singleline, | ||
allowPartialMatch: false, | ||
maxDistance: 2, | ||
onlyTopMatch) | ||
{ | ||
this.OnlyTopMatch = onlyTopMatch; | ||
} | ||
|
||
Regex IBooleanExtractorConfiguration.TrueRegex => TrueRegex; | ||
|
||
Regex IBooleanExtractorConfiguration.FalseRegex => FalseRegex; | ||
|
||
IDictionary<Regex, string> IChoiceExtractorConfiguration.MapRegexes => MapRegexes; | ||
|
||
Regex IChoiceExtractorConfiguration.TokenRegex => TokenRegex; | ||
|
||
public bool AllowPartialMatch => false; | ||
|
||
public int MaxDistance => 2; | ||
|
||
public bool OnlyTopMatch { get; } | ||
} | ||
} |
43 changes: 10 additions & 33 deletions
43
...rosoft.Recognizers.Text.Choice/Chinese/Extractors/ChineseBooleanExtractorConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,24 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
|
||
using Microsoft.Recognizers.Definitions.Chinese; | ||
using Microsoft.Recognizers.Text.Choice.Extractors; | ||
|
||
namespace Microsoft.Recognizers.Text.Choice.Chinese | ||
{ | ||
public class ChineseBooleanExtractorConfiguration : IBooleanExtractorConfiguration | ||
public class ChineseBooleanExtractorConfiguration : BaseBooleanExtractorConfiguration | ||
{ | ||
public static readonly Regex TrueRegex = | ||
new Regex(ChoiceDefinitions.TrueRegex, RegexOptions.Singleline); | ||
|
||
public static readonly Regex FalseRegex = | ||
new Regex(ChoiceDefinitions.FalseRegex, RegexOptions.Singleline); | ||
|
||
public static readonly Regex TokenRegex = | ||
new Regex(ChoiceDefinitions.TokenizerRegex, RegexOptions.Singleline); | ||
|
||
public static readonly IDictionary<Regex, string> MapRegexes = new Dictionary<Regex, string>() | ||
{ | ||
{ TrueRegex, Constants.SYS_BOOLEAN_TRUE }, | ||
{ FalseRegex, Constants.SYS_BOOLEAN_FALSE }, | ||
}; | ||
|
||
public ChineseBooleanExtractorConfiguration(bool onlyTopMatch = true) | ||
: base( | ||
trueRegex: ChoiceDefinitions.TrueRegex, | ||
falseRegex: ChoiceDefinitions.FalseRegex, | ||
tokenRegex: ChoiceDefinitions.TokenizerRegex, | ||
options: RegexOptions.Singleline, | ||
allowPartialMatch: false, | ||
maxDistance: 2, | ||
onlyTopMatch) | ||
{ | ||
this.OnlyTopMatch = onlyTopMatch; | ||
} | ||
|
||
Regex IBooleanExtractorConfiguration.TrueRegex => TrueRegex; | ||
|
||
Regex IBooleanExtractorConfiguration.FalseRegex => FalseRegex; | ||
|
||
IDictionary<Regex, string> IChoiceExtractorConfiguration.MapRegexes => MapRegexes; | ||
|
||
Regex IChoiceExtractorConfiguration.TokenRegex => TokenRegex; | ||
|
||
public bool AllowPartialMatch => false; | ||
|
||
public int MaxDistance => 2; | ||
|
||
public bool OnlyTopMatch { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 10 additions & 33 deletions
43
.../Microsoft.Recognizers.Text.Choice/Dutch/Extractors/DutchBooleanExtractorConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,24 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
|
||
using Microsoft.Recognizers.Definitions.Dutch; | ||
using Microsoft.Recognizers.Text.Choice.Extractors; | ||
|
||
namespace Microsoft.Recognizers.Text.Choice.Dutch | ||
{ | ||
public class DutchBooleanExtractorConfiguration : IBooleanExtractorConfiguration | ||
public class DutchBooleanExtractorConfiguration : BaseBooleanExtractorConfiguration | ||
{ | ||
public static readonly Regex TrueRegex = | ||
new Regex(ChoiceDefinitions.TrueRegex, RegexOptions.Singleline); | ||
|
||
public static readonly Regex FalseRegex = | ||
new Regex(ChoiceDefinitions.FalseRegex, RegexOptions.Singleline); | ||
|
||
public static readonly Regex TokenRegex = | ||
new Regex(ChoiceDefinitions.TokenizerRegex, RegexOptions.Singleline); | ||
|
||
public static readonly IDictionary<Regex, string> MapRegexes = new Dictionary<Regex, string>() | ||
{ | ||
{ TrueRegex, Constants.SYS_BOOLEAN_TRUE }, | ||
{ FalseRegex, Constants.SYS_BOOLEAN_FALSE }, | ||
}; | ||
|
||
public DutchBooleanExtractorConfiguration(bool onlyTopMatch = true) | ||
: base( | ||
trueRegex: ChoiceDefinitions.TrueRegex, | ||
falseRegex: ChoiceDefinitions.FalseRegex, | ||
tokenRegex: ChoiceDefinitions.TokenizerRegex, | ||
options: RegexOptions.Singleline, | ||
allowPartialMatch: false, | ||
maxDistance: 2, | ||
onlyTopMatch) | ||
{ | ||
this.OnlyTopMatch = onlyTopMatch; | ||
} | ||
|
||
Regex IBooleanExtractorConfiguration.TrueRegex => TrueRegex; | ||
|
||
Regex IBooleanExtractorConfiguration.FalseRegex => FalseRegex; | ||
|
||
IDictionary<Regex, string> IChoiceExtractorConfiguration.MapRegexes => MapRegexes; | ||
|
||
Regex IChoiceExtractorConfiguration.TokenRegex => TokenRegex; | ||
|
||
public bool AllowPartialMatch => false; | ||
|
||
public int MaxDistance => 2; | ||
|
||
public bool OnlyTopMatch { get; } | ||
} | ||
} |
43 changes: 10 additions & 33 deletions
43
...rosoft.Recognizers.Text.Choice/English/Extractors/EnglishBooleanExtractorConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,24 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
|
||
using Microsoft.Recognizers.Definitions.English; | ||
using Microsoft.Recognizers.Text.Choice.Extractors; | ||
|
||
namespace Microsoft.Recognizers.Text.Choice.English | ||
{ | ||
public class EnglishBooleanExtractorConfiguration : IBooleanExtractorConfiguration | ||
public class EnglishBooleanExtractorConfiguration : BaseBooleanExtractorConfiguration | ||
{ | ||
public static readonly Regex TrueRegex = | ||
new Regex(ChoiceDefinitions.TrueRegex, RegexOptions.Singleline); | ||
|
||
public static readonly Regex FalseRegex = | ||
new Regex(ChoiceDefinitions.FalseRegex, RegexOptions.Singleline); | ||
|
||
public static readonly Regex TokenRegex = | ||
new Regex(ChoiceDefinitions.TokenizerRegex, RegexOptions.Singleline); | ||
|
||
public static readonly IDictionary<Regex, string> MapRegexes = new Dictionary<Regex, string>() | ||
{ | ||
{ TrueRegex, Constants.SYS_BOOLEAN_TRUE }, | ||
{ FalseRegex, Constants.SYS_BOOLEAN_FALSE }, | ||
}; | ||
|
||
public EnglishBooleanExtractorConfiguration(bool onlyTopMatch = true) | ||
: base( | ||
trueRegex: ChoiceDefinitions.TrueRegex, | ||
falseRegex: ChoiceDefinitions.FalseRegex, | ||
tokenRegex: ChoiceDefinitions.TokenizerRegex, | ||
options: RegexOptions.Singleline, | ||
allowPartialMatch: false, | ||
maxDistance: 2, | ||
onlyTopMatch) | ||
{ | ||
this.OnlyTopMatch = onlyTopMatch; | ||
} | ||
|
||
Regex IBooleanExtractorConfiguration.TrueRegex => TrueRegex; | ||
|
||
Regex IBooleanExtractorConfiguration.FalseRegex => FalseRegex; | ||
|
||
IDictionary<Regex, string> IChoiceExtractorConfiguration.MapRegexes => MapRegexes; | ||
|
||
Regex IChoiceExtractorConfiguration.TokenRegex => TokenRegex; | ||
|
||
public bool AllowPartialMatch => false; | ||
|
||
public int MaxDistance => 2; | ||
|
||
public bool OnlyTopMatch { get; } | ||
} | ||
} |
Oops, something went wrong.