Class AltTranslation

    • Field Detail

      • ORIGIN_SOURCEDOC

        public static final String ORIGIN_SOURCEDOC
        Origin string indicating that the match is coming from a source input document (e.g. alt-trans elements in XLIFF).
        See Also:
        Constant Field Values
    • Constructor Detail

      • AltTranslation

        public AltTranslation​(LocaleId sourceLocId,
                              LocaleId targetLocId,
                              ITextUnit altTu,
                              MatchType type,
                              int combinedScore,
                              String origin)
        Creates a new AltTranslation object.
        Parameters:
        sourceLocId - the locale of the source.
        targetLocId - the locale of the target.
        altTu - the alternate ITextUnit.
        type - the type of alternate translation.
        combinedScore - the combined score for this alternate translation (must be between 0 and 100).
        origin - an optional identifier for the origin of this alternate translation.
      • AltTranslation

        public AltTranslation​(LocaleId sourceLocId,
                              LocaleId targetLocId,
                              TextFragment originalSource,
                              TextFragment alternateSource,
                              TextFragment alternateTarget,
                              MatchType type,
                              int combinedScore,
                              String origin)
        Creates a new AltTranslation object.
        Parameters:
        sourceLocId - the locale of the source.
        targetLocId - the locale of the target.
        originalSource - the original source content.
        alternateSource - the source content corresponding to the alternate translation (can be null).
        alternateTarget - the content of alternate translation.
        type - the type of alternate translation.
        combinedScore - the combined score for this alternate translation (must be between 0 and 100).
        origin - an optional identifier for the origin of this alternate translation.
      • AltTranslation

        public AltTranslation​(LocaleId sourceLocId,
                              LocaleId targetLocId,
                              TextFragment originalSource,
                              TextFragment alternateSource,
                              TextFragment alternateTarget,
                              MatchType type,
                              int combinedScore,
                              String origin,
                              int fuzzyScore,
                              int qualityScore)
        Creates a new AltTranslation object.
        Parameters:
        sourceLocId - the locale of the source.
        targetLocId - the locale of the target.
        originalSource - the original source content.
        alternateSource - the source content corresponding to the alternate translation (can be null).
        alternateTarget - the content of alternate translation.
        type - the type of alternate translation.
        combinedScore - the combined score for this alternate translation (must be between 0 and 100). Combined score is usually a combination of fuzzyScore and qualityScore.
        origin - an optional identifier for the origin of this alternate translation.
        fuzzyScore - - fuzzy score (string distance) between the original source and alternate translation source
        qualityScore - - optional quality score from the TM or MT engine
    • Method Detail

      • getTarget

        public TextContainer getTarget()
        Gets the target content of this entry.
        Returns:
        the target content of this entry.
      • setTarget

        public void setTarget​(LocaleId targetLocId,
                              TextFragment alternateTarget)
        Sets the target parts of this alternate translation.
        Parameters:
        targetLocId - the target locale.
        alternateTarget - the content of the alternate translation.
      • getSourceLocale

        public LocaleId getSourceLocale()
        Gets the source locale for this entry.
        Returns:
        the source locale for this entry.
      • getTargetLocale

        public LocaleId getTargetLocale()
        Gets the target locale for this entry.
        Returns:
        the target locale for this entry.
      • getSource

        public TextContainer getSource()
        Gets the source content of this entry (can be empty) If the result is empty, it means the source is the same as the source of the object (segment or text container) is attached to.
        Returns:
        the source content of this entry (can be empty)
      • getCombinedScore

        public int getCombinedScore()
        Gets the combined score for this entry.
        Returns:
        the combined score for this entry.
      • getOrigin

        public String getOrigin()
        Gets the origin for this entry (can be null).
        Returns:
        the origin for this entry, or null if none is defined.
      • getEngine

        public String getEngine()
        Gets the engine for this entry (can be null).
        Returns:
        the engine information for this entry, or null if none is defined.
      • getEntry

        public ITextUnit getEntry()
        Gets the text unit for this entry.
        Returns:
        the text unit for this entry.
      • getType

        public MatchType getType()
        Gets the type of this alternate translation. The value is on of the MatchType values.
        Returns:
        the type of this alternate translation.
      • setType

        public void setType​(MatchType type)
        Sets the match type of this alternate translation.
        Parameters:
        type - the new match type.
      • setCombinedScore

        public void setCombinedScore​(int score)
        Sets the score of this alternate translation.
        Parameters:
        score - the new score.
      • setOrigin

        public void setOrigin​(String origin)
        Sets the origin of this alternate translation.
        Parameters:
        origin - the new origin.
      • setEngine

        public void setEngine​(String engine)
        Sets the engine of this alternate translation. The engine is some additional information about the origin of the entry.
        Parameters:
        engine - the new engine.
      • setFromOriginal

        public void setFromOriginal​(boolean fromOriginal)
        Sets the flag indicating if this alternate translation was provided from the original document (e.g. as an alt-trans element in XLIFF).
        Parameters:
        fromOriginal - true if the match was provided by the original document.
      • getFromOriginal

        public boolean getFromOriginal()
        Indicates if this alternate translation was provided from the original document.
        Returns:
        true if the match was provided by the original document.
      • getFuzzyScore

        public int getFuzzyScore()
      • setFuzzyScore

        public void setFuzzyScore​(int fuzzyScore)
      • getQualityScore

        public int getQualityScore()
      • setQualityScore

        public void setQualityScore​(int qualityScore)
      • setTool

        public void setTool​(XLIFFTool tool)
      • fromMT

        public boolean fromMT()
        Indicator telling if the result is coming from a machine translation engine or not.
        Returns:
        true if the result is coming from a machine translation engine, false otherwise.
      • getALttransType

        public String getALttransType()
      • setAltTransType

        public void setAltTransType​(String alttranstype)
      • getExType

        public String getExType()
        Gets the exType attribute of this alt-translation. This is used to qualify further the type of the alternate translation. for example in XTM XLIFF file it specifies additional flags like "leveraged-inherited".
        Returns:
        the exType attribute of this alt-translation (can be null).
      • setExType

        public void setExType​(String exType)
        Sets the exType attribute for the alternate translation. This is used to qualify further the type of the alternate translation. for example in XTM XLIFF file it specifies additional flags like "leveraged-inherited".
        Parameters:
        exType - the value.
      • compareTo

        public int compareTo​(AltTranslation other)
        This method implements a three way sort on (1) AltTranslationType (2) Score (3) source string match. AltTranslationType is the primary key, score secondary and source string tertiary.
        Specified by:
        compareTo in interface Comparable<AltTranslation>
        Parameters:
        other - the AltTranslation we are comparing against.
        Returns:
        the comparison result (0 if both object are equal).
      • equals

        public boolean equals​(Object other)
        Define equality of state.
        Overrides:
        equals in class Object
        Parameters:
        other - the object to compare with.
        Returns:
        true if the objects are equal, false otherwise.
      • hashCode

        public int hashCode()
        A class that overrides equals must also override hashCode.
        Overrides:
        hashCode in class Object
        Returns:
        the has code for this object.