RED-2841: INC6207970 Rule for initials expansion should be applied only to dictionary entries without whitespaces

This commit is contained in:
aoezyetimoglu 2021-12-07 13:04:10 +01:00
parent 8d881d4ca6
commit 7198e1ae50

View File

@ -142,18 +142,18 @@ public class Section {
@ThenAction @ThenAction
public void expandByRegEx(@Argument(ArgumentType.TYPE) String type, public void expandByRegEx(@Argument(ArgumentType.TYPE) String type,
@Argument(ArgumentType.REGEX) String pattern, @Argument(ArgumentType.REGEX) String suffixPattern,
@Argument(ArgumentType.BOOLEAN) boolean patternCaseInsensitive, @Argument(ArgumentType.BOOLEAN) boolean patternCaseInsensitive,
@Argument(ArgumentType.INTEGER) int group, @Argument(ArgumentType.INTEGER) int group,
@Argument(ArgumentType.REGEX) String withoutPattern) { @Argument(ArgumentType.REGEX) String compiledValuePattern) {
Pattern compiledWithoutPattern = null; Pattern compiledValuePat = null;
if (withoutPattern != null) { if (compiledValuePattern != null) {
compiledWithoutPattern = Patterns.getCompiledPattern(withoutPattern, patternCaseInsensitive); compiledValuePat = Patterns.getCompiledPattern(compiledValuePattern, patternCaseInsensitive);
} }
Pattern compiledPattern = Patterns.getCompiledPattern(pattern, patternCaseInsensitive); Pattern compiledPattern = Patterns.getCompiledPattern(suffixPattern, patternCaseInsensitive);
Set<Entity> expanded = new HashSet<>(); Set<Entity> expanded = new HashSet<>();
for (Entity entity : entities) { for (Entity entity : entities) {
@ -162,9 +162,9 @@ public class Section {
continue; continue;
} }
if(withoutPattern != null) { if(compiledValuePattern != null) {
Matcher matcherWithout = compiledWithoutPattern.matcher(entity.getWord()); Matcher matcherCompiledValuePattern = compiledValuePat.matcher(entity.getWord());
if (matcherWithout.find()) { if (!matcherCompiledValuePattern.find()) {
continue; continue;
} }
} }