Class AbstractSearchParser
java.lang.Object
io.goobi.viewer.model.iiif.search.parser.AbstractSearchParser
- Direct Known Subclasses:
AltoSearchParser,SolrSearchParser
Abstract base class for IIIF Search API parsers that extract text matches from different content sources.
- Author:
- Florian Alpers
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetAutoSuggestRegex(String query) Create a regular expression matching all anything starting with the given query followed by an arbitrary number of word characters and ignoring case.static StringgetContainedWordRegex(String query) getContainedWordRegex.static StringgetPrecedingText(String text, int hitStartIndex, int maxLength) getPrecedingText.static StringgetQueryRegex(String query) getQueryRegex.static StringgetSingleWordRegex(String query) getSingleWordRegex.static StringgetSucceedingText(String text, int hitEndIndex, int maxLength) getSucceedingText.
-
Constructor Details
-
AbstractSearchParser
public AbstractSearchParser()
-
-
Method Details
-
getPrecedingText
getPrecedingText.- Parameters:
text- full text to extract context fromhitStartIndex- character index where the hit beginsmaxLength- maximum number of characters to return- Returns:
- the text excerpt preceding the hit position, up to maxLength characters
-
getSucceedingText
getSucceedingText.- Parameters:
text- full text to extract context fromhitEndIndex- character index immediately after the hit endsmaxLength- maximum number of characters to return- Returns:
- the text excerpt following the hit position, up to maxLength characters
-
getSingleWordRegex
getSingleWordRegex.- Parameters:
query- search term or regex to match as a whole word- Returns:
- a regex matching a single word matching the given query regex (ignoring case)
-
getContainedWordRegex
getContainedWordRegex.- Parameters:
query- search term or regex to find as a whole word- Returns:
- a regex matching any text containing the given query regex as single word
-
getQueryRegex
getQueryRegex.- Parameters:
query- search query with optional '*' wildcard tokens- Returns:
- a regex matching any word or sequence of words of the given query with '*' matching any number of word characters and ignoring case
-
getAutoSuggestRegex
Create a regular expression matching all anything starting with the given query followed by an arbitrary number of word characters and ignoring case.- Parameters:
query- prefix string to match at the start of words- Returns:
- the regular expression
(?i){query}[\w\d-]*
-