Package net.sf.okapi.common.query
Class QueryResult
- java.lang.Object
-
- net.sf.okapi.common.query.QueryResult
-
- All Implemented Interfaces:
Comparable<QueryResult>
public class QueryResult extends Object implements Comparable<QueryResult>
Stores one result of a query.
-
-
Field Summary
Fields Modifier and Type Field Description static intCOMBINEDSCORE_UNDEFINEDintconnectorIdID of the connector that generated this result.DatecreationDateCreation date of TM entryStringengineString providing additional information about the origin.StringentryIdUnique id of this TM entry.MatchTypematchTypeMatchTypeof this result.StringoriginString indicating the origin of the result (e.g.static intQUALITY_UNDEFINEDTextFragmentsourceText of the source for this result.TextFragmenttargetText of the target for this result.intweightWeight for this result.
-
Constructor Summary
Constructors Constructor Description QueryResult()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(QueryResult other)This method implements a five way sort on (1) weight (2)MatchType(3) Score (4) source string match and (5) creation date.booleanequals(Object other)Define equality of state.booleanfromMT()Indicator telling if the result is coming from a machine translation engine or not.intgetCombinedScore()Gets the combined score for this result.intgetFuzzyScore()Gets the fuzzy score (i.e., string distance) for this result.intgetQuality()Gets the quality rating of the translation in this result.inthashCode()A class that overrides equals must also override hashCode.voidsetCombinedScore(int combinedScore)Sets the combined score for this result.voidsetFuzzyScore(int fuzzyScore)Sets the score for this result.voidsetQuality(int quality)Sets the quality rating of the translation in this result Each connector is responsible for adjusting the original quality information (if any) to this scale.AltTranslationtoAltTranslation(TextFragment originalSource, LocaleId sourceLocId, LocaleId targetLocId)Convert a QueryResult to anAltTranslation
-
-
-
Field Detail
-
QUALITY_UNDEFINED
public static int QUALITY_UNDEFINED
-
COMBINEDSCORE_UNDEFINED
public static int COMBINEDSCORE_UNDEFINED
-
weight
public int weight
Weight for this result.
-
source
public TextFragment source
Text of the source for this result.
-
target
public TextFragment target
Text of the target for this result.
-
creationDate
public Date creationDate
Creation date of TM entry
-
entryId
public String entryId
Unique id of this TM entry. Can be null.
-
connectorId
public int connectorId
ID of the connector that generated this result.
-
origin
public String origin
String indicating the origin of the result (e.g. name of a TM). This value can be null and depends on each type of resource.
-
engine
public String engine
String providing additional information about the origin. For MT system: this can store the engine identifier for example. The value can be null and depends on each type of resource.
-
-
Method Detail
-
toAltTranslation
public AltTranslation toAltTranslation(TextFragment originalSource, LocaleId sourceLocId, LocaleId targetLocId)
Convert a QueryResult to anAltTranslation- Parameters:
originalSource- the original source content.sourceLocId- theLocaleIdof the source.targetLocId- theLocaleIdof the target.- Returns:
- an
AltTranslationcorresponding to this QueryResult
-
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.
-
getQuality
public int getQuality()
Gets the quality rating of the translation in this result.- Returns:
- A value between 0 and 100, or
QUALITY_UNDEFINEDif no quality rating is set.
-
setQuality
public void setQuality(int quality)
Sets the quality rating of the translation in this result Each connector is responsible for adjusting the original quality information (if any) to this scale.- Parameters:
quality- the new quality value (a value between 0 and 100, orQUALITY_UNDEFINEDif the value is not defined.- Throws:
InvalidParameterException- if the parameter value is not valid.
-
getCombinedScore
public int getCombinedScore()
Gets the combined score for this result.- Returns:
- the combined score for this result. If no combined score is set (default), this returns the "normal" score.
-
setCombinedScore
public void setCombinedScore(int combinedScore)
Sets the combined score for this result.- Parameters:
combinedScore- the new combined score value.This is a re-calculated score to take into account quality (when available) (a value between 0 and 100, or
COMBINEDSCORE_UNDEFINEDif the value is not defined.
-
getFuzzyScore
public int getFuzzyScore()
Gets the fuzzy score (i.e., string distance) for this result.- Returns:
- the score for this result.
- See Also:
getCombinedScore()
-
setFuzzyScore
public void setFuzzyScore(int fuzzyScore)
Sets the score for this result.- Parameters:
fuzzyScore- the new combined score value (normally a value between 0 and 100, but some systems can set higher scores).
-
compareTo
public int compareTo(QueryResult other)
This method implements a five way sort on (1) weight (2)MatchType(3) Score (4) source string match and (5) creation date. Weight is the primary key,MatchTypesecondary, score tertiary and source string quaternary.- Specified by:
compareToin interfaceComparable<QueryResult>- Parameters:
other- the QueryResult we are comparing against.- Returns:
- the comparison result (0 if both objects are equal).
-
equals
public boolean equals(Object other)
Define equality of state. Note: this class has a natural ordering that is inconsistent with equals.
-
-