net.sf.okapi.common.query

## Class QueryResult

- java.lang.Object
- - net.sf.okapi.common.query.QueryResult

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

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

  Stores one result of a query.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `COMBINEDSCORE_UNDEFINED`
    `int` | `connectorId` ID of the connector that generated this result.
    `java.util.Date` | `creationDate` Creation date of TM entry
    `java.lang.String` | `engine` String providing additional information about the origin.
    `java.lang.String` | `entryId` Unique id of this TM entry.
    `MatchType` | `matchType` `MatchType` of this result.
    `java.lang.String` | `origin` String indicating the origin of the result (e.g.
    `static int` | `QUALITY_UNDEFINED`
    `TextFragment` | `source` Text of the source for this result.
    `TextFragment` | `target` Text of the target for this result.
    `int` | `weight` Weight for this result.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `QueryResult()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `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.
    `int` | `getCombinedScore()` Gets the combined score for this result.
    `int` | `getFuzzyScore()` Gets the fuzzy score (i.e., string distance) for this result.
    `int` | `getQuality()` Gets the quality rating of the translation in this result.
    `int` | `hashCode()` A class that overrides equals must also override hashCode.
    `void` | `setCombinedScore(int combinedScore)` Sets the combined score for this result.
    `void` | `setFuzzyScore(int fuzzyScore)` Sets the score for this result.
    `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.
    `AltTranslation` | `toAltTranslation(TextFragment originalSource, LocaleId sourceLocId, LocaleId targetLocId)` Convert a QueryResult to an `AltTranslation`

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

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

- - ### Field Detail

    - #### QUALITY_UNDEFINED

          public static int QUALITY_UNDEFINED

    - #### COMBINEDSCORE_UNDEFINED

          public static int COMBINEDSCORE_UNDEFINED

    - #### weight

          public int weight

      Weight for this result.

    - #### matchType

          public MatchType matchType

      `MatchType` of 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 java.util.Date creationDate

      Creation date of TM entry

    - #### entryId

          public java.lang.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 java.lang.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 java.lang.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.

  - ### Constructor Detail

    - #### QueryResult

          public QueryResult()

  - ### Method Detail

    - #### toAltTranslation

          public AltTranslation toAltTranslation(TextFragment originalSource,
                                                 LocaleId sourceLocId,
                                                 LocaleId targetLocId)

      Convert a QueryResult to an `AltTranslation`
      Parameters:
        `originalSource` - the original source content.
        `sourceLocId` - the `LocaleId` of the source.
        `targetLocId` - the `LocaleId` of the target.
      Returns:
        an `AltTranslation` corresponding 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_UNDEFINED` if 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, or `QUALITY_UNDEFINED` if the value is not defined.
      Throws:
        `java.security.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_UNDEFINED` if 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, `MatchType` secondary, score tertiary and source string quaternary.
      Specified by:
        `compareTo` in interface `java.lang.Comparable<QueryResult>`
      Parameters:
        `other` - the QueryResult we are comparing against.
      Returns:
        the comparison result (0 if both objects are equal).

    - #### equals

          public boolean equals(java.lang.Object other)

      Define equality of state. Note: this class has a natural ordering that is inconsistent with equals.
      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 hash code for this object.