net.sf.okapi.common.annotation

## Class AltTranslation

- java.lang.Object
- - net.sf.okapi.common.annotation.AltTranslation

- All Implemented Interfaces:
    java.lang.Comparable<AltTranslation>

      public class AltTranslation
      extends java.lang.Object
      implements java.lang.Comparable<AltTranslation>

  Stores the data representing an alternate translation.

  This object is used with the `AltTranslationsAnnotation` annotation.

  Note that the content of the source and target is always un-segmented.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `ORIGIN_SOURCEDOC` Origin string indicating that the match is coming from a source input document (e.g.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AltTranslation(LocaleId sourceLocId, LocaleId targetLocId, TextFragment originalSource, TextFragment alternateSource, TextFragment alternateTarget, MatchType type, int combinedScore, java.lang.String origin)` Creates a new AltTranslation object.
    `AltTranslation(LocaleId sourceLocId, LocaleId targetLocId, TextFragment originalSource, TextFragment alternateSource, TextFragment alternateTarget, MatchType type, int combinedScore, java.lang.String origin, int fuzzyScore, int qualityScore)` Creates a new AltTranslation object.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(AltTranslation other)` This method implements a three way sort on (1) AltTranslationType (2) Score (3) source string match.
    `boolean` | `equals(java.lang.Object other)` Define equality of state.
    `boolean` | `fromMT()` Indicator telling if the result is coming from a machine translation engine or not.
    `java.lang.String` | `getALttransType()`
    `int` | `getCombinedScore()` Gets the combined score for this entry.
    `java.lang.String` | `getEngine()` Gets the engine for this entry (can be null).
    `ITextUnit` | `getEntry()` Gets the text unit for this entry.
    `boolean` | `getFromOriginal()` Indicates if this alternate translation was provided from the original document.
    `int` | `getFuzzyScore()`
    `java.lang.String` | `getOrigin()` Gets the origin for this entry (can be null).
    `int` | `getQualityScore()`
    `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.
    `LocaleId` | `getSourceLocale()` Gets the source locale for this entry.
    `TextContainer` | `getTarget()` Gets the target content of this entry.
    `LocaleId` | `getTargetLocale()` Gets the target locale for this entry.
    `XLIFFTool` | `getTool()`
    `MatchType` | `getType()` Gets the type of this alternate translation.
    `int` | `hashCode()` A class that overrides equals must also override hashCode.
    `void` | `setAltTransType(java.lang.String alttranstype)`
    `void` | `setCombinedScore(int score)` Sets the score of this alternate translation.
    `void` | `setEngine(java.lang.String engine)` Sets the engine of this alternate translation.
    `void` | `setFromOriginal(boolean fromOriginal)` Sets the flag indicating if this alternate translation was provided from the original document (e.g.
    `void` | `setFuzzyScore(int fuzzyScore)`
    `void` | `setOrigin(java.lang.String origin)` Sets the origin of this alternate translation.
    `void` | `setQualityScore(int qualityScore)`
    `void` | `setTarget(LocaleId targetLocId, TextFragment alternateTarget)` Sets the target parts of this alternate translation.
    `void` | `setTool(XLIFFTool tool)`
    `void` | `setType(MatchType type)` Sets the match type of this alternate translation.
    `java.lang.String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### ORIGIN_SOURCEDOC

          public static final java.lang.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,
                        TextFragment originalSource,
                        TextFragment alternateSource,
                        TextFragment alternateTarget,
                        MatchType type,
                        int combinedScore,
                        java.lang.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,
                        java.lang.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 java.lang.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 java.lang.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(java.lang.String origin)

      Sets the origin of this alternate translation.
      Parameters:
        `origin` - the new origin.

    - #### setEngine

          public void setEngine(java.lang.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)

    - #### getTool

          public XLIFFTool getTool()

    - #### 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 java.lang.String getALttransType()

    - #### setAltTransType

          public void setAltTransType(java.lang.String alttranstype)

    - #### 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 `java.lang.Comparable<AltTranslation>`
      Parameters:
        `other` - the AltTranslation we are comparing against.
      Returns:
        the comparison result (0 if both object are equal).

    - #### equals

          public boolean equals(java.lang.Object other)

      Define equality of state.
      Overrides:
        `equals` in class `java.lang.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 `java.lang.Object`
      Returns:
        the has code for this object.

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`