Class ConversionUtil


  • public class ConversionUtil
    extends Object
    • Constructor Detail

      • ConversionUtil

        public ConversionUtil()
    • 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
      • 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 resolve
        slt - 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)