Package com.acumenvelocity.ath.common
Class ConversionUtil
- java.lang.Object
-
- com.acumenvelocity.ath.common.ConversionUtil
-
public class ConversionUtil extends Object
-
-
Constructor Summary
Constructors Constructor Description ConversionUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static LayeredTextXtltFromLayeredSegment(LayeredSegment lseg, LayeredTextX slt)Converts a LayeredSegment to a LayeredTextX by resolving inline code references.static LayeredSegmenttoLayeredSegment(LayeredTextX slt, LayeredTextX tlt)static LayeredTextXtoLayeredText(net.sf.okapi.common.resource.TextFragment tf, net.sf.okapi.common.LocaleId loc)Converts a TextFragment (Okapi format) to a LayeredText.static List<MtTargetInfo>toMtTargets(net.sf.okapi.common.annotation.AltTranslationsAnnotation ata)static net.sf.okapi.common.resource.TextFragmenttoTextFragment(LayeredTextX fs)Converts a LayeredText to a TextFragment (Okapi format).
-
-
-
Method Detail
-
toTextFragment
public static net.sf.okapi.common.resource.TextFragment toTextFragment(LayeredTextX fs)
Converts a LayeredText to a TextFragment (Okapi format).- Parameters:
fs- the LayeredText to convert- Returns:
- TextFragment representation, or null if input is null
-
toLayeredText
public static LayeredTextX toLayeredText(net.sf.okapi.common.resource.TextFragment tf, net.sf.okapi.common.LocaleId loc)
Converts a TextFragment (Okapi format) to a LayeredText.- Parameters:
tf- the TextFragment to convert- Returns:
- LayeredText representation, or null if input is null
-
toLayeredSegment
public static LayeredSegment toLayeredSegment(LayeredTextX slt, LayeredTextX tlt)
-
tltFromLayeredSegment
public static LayeredTextX tltFromLayeredSegment(LayeredSegment lseg, LayeredTextX slt)
Converts a LayeredSegment to a LayeredTextX by resolving inline code references.This method takes the target text and code references from a LayeredSegment and matches them with full InlineCode objects from a source LayeredTextX. The code references (InlineCodeRef) contain only the id, position, and tagType, while the full InlineCode objects contain additional metadata like data, outerData, type, flags, etc.
InlineCode objects are uniquely identified by the combination of their id and tagType fields, as ids alone may not be unique (e.g., opening and closing tags may share the same id but have different tagTypes).
- Parameters:
lseg- the LayeredSegment containing target text and code references to resolveslt- the source LayeredTextX containing the full InlineCode objects to match against- Returns:
- a new LayeredTextX with the target language and text from lseg, and codes resolved from slt with positions updated from the code references. Returns null if either parameter is null.
-
toMtTargets
public static List<MtTargetInfo> toMtTargets(net.sf.okapi.common.annotation.AltTranslationsAnnotation ata)
-
-