public class QueryUtil extends Object
| Constructor and Description |
|---|
QueryUtil() |
| Modifier and Type | Method and Description |
|---|---|
TextFragment |
createNewFragmentWithCodes(String plainText)
Appends the codes stored apart using
separateCodesFromText(TextFragment) at the end of a given plain
text. |
String |
fromCodedHTML(String htmlText,
TextFragment fragment,
boolean addMissingCodes)
Converts back a coded HTML to a coded text.
|
String |
fromCodedHTML(String htmlText,
TextFragment fragment,
boolean addMissingCodes,
boolean removeSpans)
Converts back a coded HTML to a coded text.
|
TextFragment |
fromCodedHTMLToFragment(String text,
TextFragment fragment)
Converts an HTML string created with
toCodedHTML(TextFragment) back into a text fragment,
but with empty inline codes. |
String |
fromPlainTextHTML(String text)
Converts an HTML plain text into a plain text one.
|
TextFragment |
fromXLIFF(Element elem,
TextFragment original)
Converts back an XLIFF text contained in a given element into a TextFragment.
|
boolean |
hasCode()
Indicates if the last text fragment passed to
separateCodesFromText(TextFragment) has codes or not. |
static ArrayList<QueryResult> |
removeDuplicates(List<QueryResult> queryResults)
Removes duplicates based on the Equals method of
QueryResult. |
String |
separateCodesFromText(TextFragment frag)
Separate and store codes of a given text fragment.
|
List<String> |
toCodedHTML(List<TextFragment> frags)
Converts from coded texts to coded HTML.
|
String |
toCodedHTML(TextFragment fragment)
Converts from coded text to coded HTML.
|
String |
toXLIFF(TextFragment fragment)
Converts from coded text to XLIFF.
|
public boolean hasCode()
separateCodesFromText(TextFragment) has codes or not.public String separateCodesFromText(TextFragment frag)
frag - the fragment to process. Use createNewFragmentWithCodes(String) to
reconstruct the text back with its codes at the end.public TextFragment createNewFragmentWithCodes(String plainText)
separateCodesFromText(TextFragment) at the end of a given plain
text. The text fragment provided must be the same and without code modifications, as the one used for the
splitting.plainText - new text to use (must be plain)public List<String> toCodedHTML(List<TextFragment> frags)
frags - the fragments to convert.public String toCodedHTML(TextFragment fragment)
fragment - the fragment to convert.public TextFragment fromCodedHTMLToFragment(String text, TextFragment fragment)
toCodedHTML(TextFragment) back into a text fragment,
but with empty inline codes.text - the HTML string to convert.fragment - an optional text fragment where to place the converted content. Any existing codes will be
replaced or removed by the codes coming from the HTML string. Use null to create a new fragment.public String fromCodedHTML(String htmlText, TextFragment fragment, boolean addMissingCodes)
htmlText - the coded HTML to convert back.fragment - the original text fragment.addMissingCodes - true to added codes that are in the original fragment but not in the HTML string.public String fromCodedHTML(String htmlText, TextFragment fragment, boolean addMissingCodes, boolean removeSpans)
htmlText - the coded HTML to convert back.fragment - the original text fragment.addMissingCodes - true to added codes that are in the original fragment but not in the HTML string.removeSpans - true to remove extra span HTML codes.public String fromPlainTextHTML(String text)
This method assumes there is no elements in the text, just escaped characters. The methods supported NCRs as well as HTML CERs.
text - the HTML string to convert.public String toXLIFF(TextFragment fragment)
fragment - the fragment to convert.fromXLIFF(Element, TextFragment)public TextFragment fromXLIFF(Element elem, TextFragment original)
elem - The element containing the XLIFF data.original - the original TextFragment (cannot be null).toXLIFF(TextFragment)public static ArrayList<QueryResult> removeDuplicates(List<QueryResult> queryResults)
QueryResult.
Preserve the highest ranked query results.
For example, duplicate results with the newest creation date are always retained.queryResults - the list of QueryResults to process.Copyright © 2019. All rights reserved.