Package org.opencms.ai
Class CmsAiTranslator.HtmlParseResult
java.lang.Object
org.opencms.ai.CmsAiTranslator.HtmlParseResult
- Enclosing class:
CmsAiTranslator
Holder for parsed HTML text nodes and helper operations.
-
Constructor Summary
ConstructorsConstructorDescriptionHtmlParseResult(org.jsoup.nodes.Document doc, List<org.jsoup.nodes.TextNode> textNodes, boolean isFullDocument) Creates a new parse result. -
Method Summary
Modifier and TypeMethodDescriptionorg.jsoup.nodes.DocumentReturns the parsed document.List<org.jsoup.nodes.TextNode> Returns the collected text nodes.booleanReturns true if the input represented a full document.setTranslatedString(String translation) Applies a translated string to the text nodes and returns the HTML output.splitTranslateString(String input) Splits a translation string into segments by marker tokens.toString()Returns a string representation of the HTML of the parsed document.Returns a concatenated string with markers between text nodes.
-
Constructor Details
-
HtmlParseResult
public HtmlParseResult(org.jsoup.nodes.Document doc, List<org.jsoup.nodes.TextNode> textNodes, boolean isFullDocument) Creates a new parse result.- Parameters:
doc- the parsed documenttextNodes- the collected text nodesisFullDocument- true if input is a full HTML document
-
-
Method Details
-
splitTranslateString
Splits a translation string into segments by marker tokens.- Parameters:
input- the translation string- Returns:
- the list of segments
-
getDocument
Returns the parsed document.- Returns:
- the parsed document
-
getTextNodes
Returns the collected text nodes.- Returns:
- the collected text nodes
-
isFullDocument
Returns true if the input represented a full document.- Returns:
- true if the input is a full document
-
setTranslatedString
Applies a translated string to the text nodes and returns the HTML output.- Parameters:
translation- the translated string- Returns:
- the resulting HTML
- Throws:
CmsAiException- if the translation does not match the text node count
-
toString
Returns a string representation of the HTML of the parsed document. -
toTranslateString
Returns a concatenated string with markers between text nodes.- Returns:
- the translation input string
-