Package net.sf.okapi.common.annotation
Class AltTranslation
- java.lang.Object
-
- net.sf.okapi.common.annotation.AltTranslation
-
- All Implemented Interfaces:
Comparable<AltTranslation>
public class AltTranslation extends Object implements Comparable<AltTranslation>
Stores the data representing an alternate translation.This object is used with the
AltTranslationsAnnotationannotation.Note that the content of the source and target is always un-segmented.
-
-
Field Summary
Fields Modifier and Type Field Description static StringORIGIN_SOURCEDOCOrigin string indicating that the match is coming from a source input document (e.g.
-
Constructor Summary
Constructors Constructor Description AltTranslation(LocaleId sourceLocId, LocaleId targetLocId, ITextUnit altTu, MatchType type, int combinedScore, String origin)Creates a new AltTranslation object.AltTranslation(LocaleId sourceLocId, LocaleId targetLocId, TextFragment originalSource, TextFragment alternateSource, TextFragment alternateTarget, MatchType type, int combinedScore, String origin)Creates a new AltTranslation object.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(AltTranslation other)This method implements a three way sort on (1) AltTranslationType (2) Score (3) source string match.booleanequals(Object other)Define equality of state.booleanfromMT()Indicator telling if the result is coming from a machine translation engine or not.StringgetALttransType()intgetCombinedScore()Gets the combined score for this entry.StringgetEngine()Gets the engine for this entry (can be null).ITextUnitgetEntry()Gets the text unit for this entry.StringgetExType()Gets the exType attribute of this alt-translation.booleangetFromOriginal()Indicates if this alternate translation was provided from the original document.intgetFuzzyScore()StringgetOrigin()Gets the origin for this entry (can be null).intgetQualityScore()TextContainergetSource()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.LocaleIdgetSourceLocale()Gets the source locale for this entry.TextContainergetTarget()Gets the target content of this entry.LocaleIdgetTargetLocale()Gets the target locale for this entry.ITextUnitgetTextUnit()Get theAltTranslationXLIFFToolgetTool()MatchTypegetType()Gets the type of this alternate translation.inthashCode()A class that overrides equals must also override hashCode.voidsetAltTransType(String alttranstype)voidsetCombinedScore(int score)Sets the score of this alternate translation.voidsetEngine(String engine)Sets the engine of this alternate translation.voidsetExType(String exType)Sets the exType attribute for the alternate translation.voidsetFromOriginal(boolean fromOriginal)Sets the flag indicating if this alternate translation was provided from the original document (e.g.voidsetFuzzyScore(int fuzzyScore)voidsetOrigin(String origin)Sets the origin of this alternate translation.voidsetQualityScore(int qualityScore)voidsetTarget(LocaleId targetLocId, TextFragment alternateTarget)Sets the target parts of this alternate translation.voidsetTool(XLIFFTool tool)voidsetType(MatchType type)Sets the match type of this alternate translation.StringtoString()
-
-
-
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 alternateITextUnit.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 sourcequalityScore- - 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.
-
getTextUnit
public ITextUnit getTextUnit()
Get theAltTranslation- Returns:
- The
AltTranslationas aITextUnit
-
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 theMatchTypevalues.- 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)
-
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 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:
compareToin interfaceComparable<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.
-
hashCode
public int hashCode()
A class that overrides equals must also override hashCode.
-
-