RED-6807: updated EntityCreationService and RedactionSearchUtility to combine...
This commit is contained in:
parent
6031d7c576
commit
b543952c4a
@ -165,6 +165,24 @@ public class EntityCreationService {
|
||||
}
|
||||
|
||||
|
||||
public Stream<TextEntity> shortestBetweenAnyString(List<String> starts, List<String> stops, String type, EntityType entityType, SemanticNode node) {
|
||||
|
||||
List<TextRange> startTextRanges = RedactionSearchUtility.findTextRangesByList(starts, node.getTextBlock());
|
||||
List<TextRange> stopTextRanges = RedactionSearchUtility.findTextRangesByList(stops, node.getTextBlock());
|
||||
|
||||
return betweenTextRanges(startTextRanges, stopTextRanges, type, entityType, node);
|
||||
}
|
||||
|
||||
|
||||
public Stream<TextEntity> shortestBetweenAnyStringIgnoreCase(List<String> starts, List<String> stops, String type, EntityType entityType, SemanticNode node) {
|
||||
|
||||
List<TextRange> startTextRanges = RedactionSearchUtility.findTextRangesByListIgnoreCase(starts, node.getTextBlock());
|
||||
List<TextRange> stopTextRanges = RedactionSearchUtility.findTextRangesByListIgnoreCase(stops, node.getTextBlock());
|
||||
|
||||
return betweenTextRanges(startTextRanges, stopTextRanges, type, entityType, node);
|
||||
}
|
||||
|
||||
|
||||
public Stream<TextEntity> betweenRegexes(String regexStart, String regexStop, String type, EntityType entityType, SemanticNode node) {
|
||||
|
||||
TextBlock textBlock = node.getTextBlock();
|
||||
|
||||
@ -179,4 +179,22 @@ public class RedactionSearchUtility {
|
||||
return getTextRangesByPattern(textBlock, 0, pattern);
|
||||
}
|
||||
|
||||
public static List<TextRange> findTextRangesByList(List<String> searchList, TextBlock textBlock) {
|
||||
|
||||
List<TextRange> boundaries = new LinkedList<>();
|
||||
for (var searchString: searchList) {
|
||||
boundaries.addAll(findTextRangesByString(searchString, textBlock));
|
||||
}
|
||||
return boundaries;
|
||||
}
|
||||
|
||||
public static List<TextRange> findTextRangesByListIgnoreCase(List<String> searchList, TextBlock textBlock) {
|
||||
|
||||
List<TextRange> boundaries = new LinkedList<>();
|
||||
for (var searchString: searchList) {
|
||||
boundaries.addAll(findTextRangesByStringIgnoreCase(searchString, textBlock));
|
||||
}
|
||||
return boundaries;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user