Class SearchResultConverter
java.lang.Object
io.goobi.viewer.model.iiif.search.SearchResultConverter
Converts resources found in a search to IIIF Search objects
- Author:
- florian
-
Constructor Summary
ConstructorDescriptionSearchResultConverter
(AbstractApiUrlManager urls, String pi, Integer pageNo) Create a new converter; parameters are used to construct urls or result resources -
Method Summary
Modifier and TypeMethodDescriptionde.intranda.api.iiif.search.SearchHit
convertAltoToHit
(List<de.intranda.digiverso.ocr.alto.model.structureclasses.lineelements.Word> altoElements) Convert a list of also word elements to a search hit, containing an annotation for each word in the listde.intranda.api.iiif.search.SearchHit
convertCommentToHit
(String queryRegex, String pi, Comment comment) Generates a search hit from aComment
de.intranda.api.iiif.search.SearchHit
convertMetadataToHit
(String queryRegex, String fieldName, org.apache.solr.common.SolrDocument doc) Create a IIIF Search hit from the field fieldName within the SolrDocumnet docde.intranda.api.iiif.search.SearchHit
convertUGCToHit
(String queryRegex, org.apache.solr.common.SolrDocument ugc) Create a IIIF Search hit from a UGC solr document (usually a crowdsourcing created comment/metadata)de.intranda.api.iiif.search.SearchHit
createAltoHit
(List<de.intranda.digiverso.ocr.alto.model.structureclasses.Line> lines, org.apache.commons.lang3.Range<Integer> position, List<de.intranda.digiverso.ocr.alto.model.structureclasses.Line> containingLines) Creates aSearchHit
of the text within the given position within the given lines.de.intranda.api.iiif.search.SearchHit
createFulltextHit
(String queryRegex, String text, String pi, Integer pageNo) Create a SearchHit for the given text.getAnnotationsFromAlto
(Path path, String query) Create annotations for all matches of the given query within the given alto filegetAnnotationsFromFulltext
(String text, String pi, Integer pageNo, String query, long previousHitCount, int firstIndex, int numHits) Create annotations for all matches of the given query within the given text file Returns only a partial result if the firstIndex is larger than 0 and numHits is smaller than the total number of hitsGetter for the fieldpageNo
.getPi()
Getter for the fieldpi
.Getter for the fieldpresentationBuilder
.getSearchTerms
(String regex, String value, List<String> searchMotivation) Get all matches to the given regex in the given value asSearchTerms
getSearchTerms
(String regex, org.apache.solr.common.SolrDocument doc, List<String> fieldsToSearch, List<String> searchMotivation) Get all matches to the given regex in the fieldsToSearch of the given doc asSearchTerms
void
Setter for the fieldpageNo
.void
Setter for the fieldpi
.
-
Constructor Details
-
SearchResultConverter
Create a new converter; parameters are used to construct urls or result resources- Parameters:
urls
-pi
- The PI of the manifest to searchpageNo
- The page number of generated resources
-
-
Method Details
-
setPi
Setter for the field
pi
.- Parameters:
pi
- aString
object.
-
getPi
Getter for the field
pi
.- Returns:
- a
String
object.
-
setPageNo
Setter for the field
pageNo
.- Parameters:
pageNo
- aInteger
object.
-
getPageNo
Getter for the field
pageNo
.- Returns:
- a
Integer
object.
-
getPresentationBuilder
Getter for the field
presentationBuilder
.- Returns:
- a
AbstractBuilder
object.
-
convertCommentToHit
public de.intranda.api.iiif.search.SearchHit convertCommentToHit(String queryRegex, String pi, Comment comment) Generates a search hit from aComment
- Parameters:
pi
- The PI of the work containing the commentqueryRegex
- The regex matching the search termscomment
- The comment containing the search terms- Returns:
- a
SearchHit
-
convertUGCToHit
public de.intranda.api.iiif.search.SearchHit convertUGCToHit(String queryRegex, org.apache.solr.common.SolrDocument ugc) Create a IIIF Search hit from a UGC solr document (usually a crowdsourcing created comment/metadata)- Parameters:
queryRegex
- aString
object.ugc
- aSolrDocument
object.- Returns:
- A search hit matching the queryRegex within the given UGC SolrDocument
-
convertMetadataToHit
public de.intranda.api.iiif.search.SearchHit convertMetadataToHit(String queryRegex, String fieldName, org.apache.solr.common.SolrDocument doc) Create a IIIF Search hit from the field fieldName within the SolrDocumnet doc -
getAnnotationsFromAlto
public AnnotationResultList getAnnotationsFromAlto(Path path, String query) throws IOException, org.jdom2.JDOMException Create annotations for all matches of the given query within the given alto file- Parameters:
path
-query
- a regex; each match of the query within the alto document creates aSearchHit
with one or more annotations referencing alto word or line elements- Returns:
- A result list containing hits for each mach of the query and annotations containing the hits
- Throws:
org.jdom2.JDOMException
IOException
-
getAnnotationsFromFulltext
public AnnotationResultList getAnnotationsFromFulltext(String text, String pi, Integer pageNo, String query, long previousHitCount, int firstIndex, int numHits) Create annotations for all matches of the given query within the given text file Returns only a partial result if the firstIndex is larger than 0 and numHits is smaller than the total number of hits- Parameters:
text
- the text to searchpi
- the PI of the work containing the annotationspageNo
- The page number of the canvas containing the annotationsquery
- The regex matching all hits in the text filepreviousHitCount
- The number of hits already found in previous pagesfirstIndex
- The index of the first overal hit to be returned in the result itself. Larger than 0 only for later pages within a paged annotation collectionnumHits
- The maximal number of hits to be returned in the result itself. This is the maximal size of the hit list within a single result page of a paged annotation collection- Returns:
- A result list containing all matching hits within the range set by previousHitCount, firstIndex and numHits
-
getSearchTerms
public SearchTermList getSearchTerms(String regex, org.apache.solr.common.SolrDocument doc, List<String> fieldsToSearch, List<String> searchMotivation) Get all matches to the given regex in the fieldsToSearch of the given doc asSearchTerms
- Parameters:
regex
- A regex matching all text wich should be returned as a searchTermdoc
- The document within to searchfieldsToSearch
- The fields to search for the regexsearchMotivation
- The motivation to be set for the search url of the searchTerms- Returns:
- A list of search terms
-
getSearchTerms
Get all matches to the given regex in the given value asSearchTerms
- Parameters:
regex
- A regex matching all text wich should be returned as a searchTermvalue
- The text to be searched with the regexsearchMotivation
- The motivation to be set for the search url of the searchTerms- Returns:
- A list of search terms
-
convertAltoToHit
public de.intranda.api.iiif.search.SearchHit convertAltoToHit(List<de.intranda.digiverso.ocr.alto.model.structureclasses.lineelements.Word> altoElements) Convert a list of also word elements to a search hit, containing an annotation for each word in the list- Parameters:
altoElements
- A list of ALTO word elements- Returns:
- A hit of the combined words
-
createAltoHit
public de.intranda.api.iiif.search.SearchHit createAltoHit(List<de.intranda.digiverso.ocr.alto.model.structureclasses.Line> lines, org.apache.commons.lang3.Range<Integer> position, List<de.intranda.digiverso.ocr.alto.model.structureclasses.Line> containingLines) Creates aSearchHit
of the text within the given position within the given lines.- Parameters:
lines
- The lines containing the hitposition
- A range covering character positions of the matched text. the position is relative to the entire text of the given linescontainingLines
- The lines to be included as annotations in the hit- Returns:
- A search hit containing the match at the given position
-
createFulltextHit
public de.intranda.api.iiif.search.SearchHit createFulltextHit(String queryRegex, String text, String pi, Integer pageNo) Create a SearchHit for the given text. Each match of the given queryRegex in the text is included as a TextQuoteSelector in the hit- Parameters:
queryRegex
- The regex matching the hittext
- The text to searchpi
- The PI of the manifest containing the annotationspageNo
- The order of the canvas containing the annotations- Returns:
- A search hit containing a TextQuoteSelector for each match of the regex and a single annotations covering the entire text
-