Class RedactionSearchUtility
java.lang.Object
com.iqser.red.service.redaction.v1.server.utils.RedactionSearchUtility
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
anyMatch
(com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock, String regexPattern) Checks if any part of a TextBlock matches a given regex pattern.static boolean
anyMatch
(CharSequence charSequence, String regexPattern) Checks if any part of a CharSequence matches a given regex pattern.static boolean
anyMatchIgnoreCase
(com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock, String regexPattern) Checks if any part of a TextBlock matches a given regex pattern, case-insensitive.static boolean
anyMatchIgnoreCase
(CharSequence charSequence, String regexPattern) Checks if any part of a CharSequence matches a given regex pattern, case-insensitive.static boolean
exactMatch
(CharSequence charSequence, String regexPattern) Checks if the entirety of a CharSequence exactly matches a given regex pattern.static TextRange
findFirstTextRange
(String regexPattern, CharSequence searchText) Finds the first TextRange in a given CharSequence that matches a regex pattern.findTextRangesByList
(List<String> searchList, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Searches a text block for all occurrences of each string in a list and returns their positions as text ranges.findTextRangesByListIgnoreCase
(List<String> searchList, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Searches a text block for all occurrences of each string in a list, case-insensitive, and returns their positions as text ranges.findTextRangesByRegex
(String regexPattern, int group, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Finds TextRanges matching a regex pattern within a TextBlock capturing groups.findTextRangesByRegex
(String regexPattern, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Finds TextRanges matching a regex pattern within a TextBlock.findTextRangesByRegexIgnoreCase
(String regexPattern, int group, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Finds text ranges within a text block that match a given regex pattern, capturing a specific group, and case-insensitive.findTextRangesByRegexIgnoreCase
(String regexPattern, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Finds text ranges within a text block that match a given regex pattern, and case-insensitive.findTextRangesByRegexWithLineBreaks
(String regexPattern, int group, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Finds text ranges that match a regex pattern with consideration for line breaks within a text block.findTextRangesByRegexWithLineBreaksIgnoreCase
(String regexPattern, int group, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Finds text ranges within a text block that match a given regex pattern, case-insensitive.findTextRangesByString
(String searchString, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Finds all occurrences of a specified string within a text block and returns their positions as text ranges.findTextRangesByStringIgnoreCase
(String searchString, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Finds all occurrences of a specified string within a text block, case-insensitive, and returns their positions as text ranges.static TextRange
findTextRangesOfAllLinesInYRange
(double maxY, double minY, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Identifies all lines within a text block that fall within a specified vertical range.static TextRange
findTextRangesOfAllLinesWithCloseYCoordinates
(Double maxY, Double minY, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Identifies all lines within a text block that have roughly the same vertical coordinates.static int
getExpandedEndByRegex
(com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity entity, String regexPattern) Expands the end boundary of a TextEntity based on a subsequent regex match.static int
getExpandedStartByRegex
(com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity entity, String regexPattern) Expands the start boundary of a TextEntity based on a subsequent regex match.
-
Method Details
-
anyMatch
Checks if any part of a CharSequence matches a given regex pattern.- Parameters:
charSequence
- The CharSequence to be searched.regexPattern
- The regex pattern to match against.- Returns:
- true if any part of the CharSequence matches the regex pattern.
-
anyMatchIgnoreCase
Checks if any part of a CharSequence matches a given regex pattern, case-insensitive.- Parameters:
charSequence
- The CharSequence to be searched.regexPattern
- The regex pattern to match against.- Returns:
- true if any part of the CharSequence matches the regex pattern.
-
exactMatch
Checks if the entirety of a CharSequence exactly matches a given regex pattern.- Parameters:
charSequence
- The CharSequence to be matched.regexPattern
- The regex pattern to match against.- Returns:
- true if the CharSequence exactly matches the regex pattern.
-
anyMatchIgnoreCase
public static boolean anyMatchIgnoreCase(com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock, String regexPattern) Checks if any part of a TextBlock matches a given regex pattern, case-insensitive.- Parameters:
textBlock
- The TextBlock to be searched.regexPattern
- The regex pattern to match against.- Returns:
- true if any part of the TextBlock matches the regex pattern.
-
anyMatch
public static boolean anyMatch(com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock, String regexPattern) Checks if any part of a TextBlock matches a given regex pattern.- Parameters:
textBlock
- The TextBlock to be searched.regexPattern
- The regex pattern to match against.- Returns:
- true if any part of the TextBlock matches the regex pattern.
-
findFirstTextRange
Finds the first TextRange in a given CharSequence that matches a regex pattern.- Parameters:
regexPattern
- The regex pattern to match against.searchText
- The CharSequence to be searched.- Returns:
- The first TextRange that matches the pattern.
- Throws:
IllegalArgumentException
- If no match is found.
-
getExpandedEndByRegex
public static int getExpandedEndByRegex(com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity entity, String regexPattern) Expands the end boundary of a TextEntity based on a subsequent regex match.- Parameters:
entity
- The entity to expand.regexPattern
- The regex pattern used for expansion.- Returns:
- The new end boundary index.
-
getExpandedStartByRegex
public static int getExpandedStartByRegex(com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity entity, String regexPattern) Expands the start boundary of a TextEntity based on a subsequent regex match.- Parameters:
entity
- The entity to expand.regexPattern
- The regex pattern used for expansion.- Returns:
- The new end boundary index.
-
findTextRangesOfAllLinesInYRange
public static TextRange findTextRangesOfAllLinesInYRange(double maxY, double minY, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Identifies all lines within a text block that fall within a specified vertical range.- Parameters:
maxY
- The maximum Y-coordinate of the vertical range.minY
- The minimum Y-coordinate of the vertical range.textBlock
- The text block containing the lines to be checked.- Returns:
- A
TextRange
encompassing all lines within the specified Y-coordinate range.
-
findTextRangesOfAllLinesWithCloseYCoordinates
public static TextRange findTextRangesOfAllLinesWithCloseYCoordinates(Double maxY, Double minY, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Identifies all lines within a text block that have roughly the same vertical coordinates.- Parameters:
maxY
- The maximum Y-coordinate of the vertical range.minY
- The minimum Y-coordinate of the vertical range.textBlock
- The text block containing the lines to be checked.- Returns:
- A
TextRange
encompassing all lines within the specified Y-coordinate range.
-
findTextRangesByRegex
public static List<TextRange> findTextRangesByRegex(String regexPattern, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Finds TextRanges matching a regex pattern within a TextBlock.- Parameters:
regexPattern
- The regex pattern to match against.textBlock
- The TextBlock to search within.- Returns:
- A list of TextRanges corresponding to regex matches.
-
findTextRangesByRegex
public static List<TextRange> findTextRangesByRegex(String regexPattern, int group, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Finds TextRanges matching a regex pattern within a TextBlock capturing groups.- Parameters:
regexPattern
- The regex pattern to match against.group
- The group to capture within the regex pattern.textBlock
- The TextBlock to search within.- Returns:
- A list of TextRanges corresponding to regex matches.
-
findTextRangesByRegexWithLineBreaks
public static List<TextRange> findTextRangesByRegexWithLineBreaks(String regexPattern, int group, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Finds text ranges that match a regex pattern with consideration for line breaks within a text block.- Parameters:
regexPattern
- The regex pattern to search for, allowing for multiline matches.group
- The regex pattern group to extract from matches.textBlock
- The text block to search within.- Returns:
- A list of
TextRange
objects corresponding to the matches found.
-
findTextRangesByRegexWithLineBreaksIgnoreCase
public static List<TextRange> findTextRangesByRegexWithLineBreaksIgnoreCase(String regexPattern, int group, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Finds text ranges within a text block that match a given regex pattern, case-insensitive.- Parameters:
regexPattern
- The regex pattern to search for, with case-insensitive matching.textBlock
- The text block to search within.- Returns:
- A list of
TextRange
objects corresponding to the matches found.
-
findTextRangesByRegexIgnoreCase
public static List<TextRange> findTextRangesByRegexIgnoreCase(String regexPattern, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Finds text ranges within a text block that match a given regex pattern, and case-insensitive.- Parameters:
regexPattern
- The regex pattern to search for.textBlock
- The text block to search within.- Returns:
- A list of
TextRange
objects corresponding to the group matches found, with case-insensitive matching.
-
findTextRangesByRegexIgnoreCase
public static List<TextRange> findTextRangesByRegexIgnoreCase(String regexPattern, int group, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Finds text ranges within a text block that match a given regex pattern, capturing a specific group, and case-insensitive.- Parameters:
regexPattern
- The regex pattern to search for.group
- The group within the regex pattern to capture.textBlock
- The text block to search within.- Returns:
- A list of
TextRange
objects corresponding to the group matches found, with case-insensitive matching.
-
findTextRangesByString
public static List<TextRange> findTextRangesByString(String searchString, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Finds all occurrences of a specified string within a text block and returns their positions as text ranges.- Parameters:
searchString
- The string to search for within the text block.textBlock
- The text block to search within.- Returns:
- A list of
TextRange
objects representing the start and end positions of each occurrence of the search string.
-
findTextRangesByStringIgnoreCase
public static List<TextRange> findTextRangesByStringIgnoreCase(String searchString, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Finds all occurrences of a specified string within a text block, case-insensitive, and returns their positions as text ranges.- Parameters:
searchString
- The string to search for within the text block, case-insensitively.textBlock
- The text block to search within.- Returns:
- A list of
TextRange
objects representing the start and end positions of each occurrence of the search string, case-insensitive.
-
findTextRangesByList
public static List<TextRange> findTextRangesByList(List<String> searchList, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Searches a text block for all occurrences of each string in a list and returns their positions as text ranges.- Parameters:
searchList
- A list of strings to search for within the text block.textBlock
- The text block to search within.- Returns:
- A list of
TextRange
objects representing the start and end positions of occurrences of each string in the list.
-
findTextRangesByListIgnoreCase
public static List<TextRange> findTextRangesByListIgnoreCase(List<String> searchList, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) Searches a text block for all occurrences of each string in a list, case-insensitive, and returns their positions as text ranges.- Parameters:
searchList
- A list of strings to search for within the text block, case-insensitively.textBlock
- The text block to search within.- Returns:
- A list of
TextRange
objects representing the start and end positions of occurrences of each string in the list, case-insensitive.
-