Package net.sf.okapi.lib.xliff2.matches
Class Match
- java.lang.Object
-
- net.sf.okapi.lib.xliff2.matches.Match
-
- All Implemented Interfaces:
IWithExtAttributes,IWithExtElements,IWithMetadata,IWithStore
public class Match extends Object implements IWithExtElements, IWithExtAttributes, IWithMetadata, IWithStore
Represents the <match> element of the Translation Candidates module.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_TYPEDefault value for thetypeattribute of <match>.static StringELEM_MTC_MATCHstatic StringMATCH_REF_PREFIX
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Matchannotate(Fragment fragment, int start, int end, Match match)Tries to reuse an existingmtc:matchannotation to add a given match.StringgetAnnotatorRef()Gets the ITS annotator reference for this match.ExtAttributesgetExtAttributes()Gets theExtAttributesobject for the parent object.StringgetExtAttributeValue(String namespaceURI, String localName)Gets the value for a given extension attribute.ExtElementsgetExtElements()Gets theExtElementsobject associated with this object.StringgetId()Gets the id for this match.DoublegetMatchQuality()Gets the quality for this match.DoublegetMatchSuitability()Gets the suitability for this match.MetadatagetMetadata()Gets theMetadataobject for the parent, creates an empty of if there is none.DoublegetMTConfidence()Gets the ITS MT Confidence for this match.StringgetOrigin()Gets the origin for this match.StringgetRef()Gets the ref for this match.DoublegetSimilarity()Gets the similarity value for this matchFragmentgetSource()Gets the source fragment for this match.DirectionalitygetSourceDir()StoregetStore()Gets theStoreobject associated with this match.StringgetSubType()Gets the subType for this match.FragmentgetTarget()Gets the target fragment for this match.DirectionalitygetTargetDir()StringgetType()Gets the type for this match.booleanhasExtAttribute()Indicates if at least one extension attribute is present.booleanhasExtElements()Indicates if there is aExtElementsobject associated with this object.booleanhasMetadata()Indicates if the object has metadata.booleanisIdUsed(String id)booleanisReference()Gets the reference for this match.voidsetAnnoatorRef(String annotatorRef)Sets the the ITS annotator reference for this match.voidsetExtAttributes(ExtAttributes attributes)Sets theExtAttributesobject associated with this object.ExtElementssetExtElements(ExtElements elements)Sets theExtElementsobject associated with this object.voidsetId(String id)Sets the id for this match.voidsetMatchQuality(Double matchQuality)Sets the quality for this match.voidsetMatchSuitability(Double matchSuitability)Sets the suitability for this match.voidsetMetadata(Metadata metadata)sets theMetadataobject for the parent.voidsetMTConfidence(Double mtConfidence)Sets the ITS MT Confidence for this match.voidsetOrigin(String origin)Sets the origin for this match.voidsetRef(String ref)Sets the ref for this match.voidsetReference(boolean reference)Sets the reference for this match.voidsetSimilarity(Double similarity)Sets the similarity value for this match.voidsetSource(Fragment source)Sets the source fragment for this match.voidsetSourceDir(Directionality dir)voidsetSubType(String subType)Sets the subType for this match.voidsetTarget(Fragment target)Sets the target fragment for this match.voidsetTargetDir(Directionality dir)voidsetType(String type)Sets the type for this match.
-
-
-
Field Detail
-
ELEM_MTC_MATCH
public static final String ELEM_MTC_MATCH
- See Also:
- Constant Field Values
-
MATCH_REF_PREFIX
public static final String MATCH_REF_PREFIX
- See Also:
- Constant Field Values
-
DEFAULT_TYPE
public static final String DEFAULT_TYPE
Default value for thetypeattribute of <match>.- See Also:
- Constant Field Values
-
-
Method Detail
-
annotate
public static Match annotate(Fragment fragment, int start, int end, Match match)
Tries to reuse an existingmtc:matchannotation to add a given match. If no existing annotation is found for the given span, one is created. Therefattribute of the match is set to the id of the annotation, and the match object is added to the list of matches for the unit.- Parameters:
fragment- the fragment to annotate.start- the start position (in the coded text)end- the position just after the last character of the span (in the coded text). You can use -1 to indicate the end of the fragment.match- theMatchto set with the annotation.- Returns:
- the match that was added.
-
getStore
public Store getStore()
Gets theStoreobject associated with this match.- Specified by:
getStorein interfaceIWithStore- Returns:
- the store associated with this match (never null).
-
getId
public String getId()
Gets the id for this match.- Returns:
- the id for this match (can be null).
-
setId
public void setId(String id)
Sets the id for this match.- Parameters:
id- the new id to set (can be null).
-
getType
public String getType()
Gets the type for this match.- Returns:
- the type for this match (never null).
-
setType
public void setType(String type)
Sets the type for this match.- Parameters:
type- the type to set (Use null to set the default (DEFAULT_TYPE)).
-
getSubType
public String getSubType()
Gets the subType for this match.- Returns:
- the subType for this match (can be null).
-
setSubType
public void setSubType(String subType)
Sets the subType for this match.- Parameters:
subType- the new subType to set (can be null).
-
getSimilarity
public Double getSimilarity()
Gets the similarity value for this match- Returns:
- the similarity value for this match (between 0.0 and 100.0 or can be null).
-
setSimilarity
public void setSimilarity(Double similarity)
Sets the similarity value for this match.- Parameters:
similarity- the new similarity value to set (between 0.0 and 100.0 or can be null).
-
getMatchQuality
public Double getMatchQuality()
Gets the quality for this match.- Returns:
- the quality for this match (between 0.0 and 100.0 or can be null).
- See Also:
getMTConfidence()
-
setMatchQuality
public void setMatchQuality(Double matchQuality)
Sets the quality for this match.- Parameters:
matchQuality- the new quality to set (between 0.0 and 100.0 or can be null).- See Also:
setMTConfidence(Double)
-
getMatchSuitability
public Double getMatchSuitability()
Gets the suitability for this match.- Returns:
- the suitability for this match (between 0.0 and 100.0 or can be null).
-
setMatchSuitability
public void setMatchSuitability(Double matchSuitability)
Sets the suitability for this match.- Parameters:
matchSuitability- the new suitability to set (between 0.0 and 100.0 or can be null).
-
getRef
public String getRef()
Gets the ref for this match.- Returns:
- the ref for this match (an IRI or can be null)
-
setRef
public void setRef(String ref)
Sets the ref for this match.- Parameters:
ref- the new ref value to set (an IRI or can be null)
-
getOrigin
public String getOrigin()
Gets the origin for this match.- Returns:
- the origin for this match (can be null).
-
setOrigin
public void setOrigin(String origin)
Sets the origin for this match.- Parameters:
origin- the new origin value for this match (can be null).
-
isReference
public boolean isReference()
Gets the reference for this match.- Returns:
- the reference for this match.
-
setReference
public void setReference(boolean reference)
Sets the reference for this match.- Parameters:
reference- the new reference value for this match.
-
getSource
public Fragment getSource()
Gets the source fragment for this match.- Returns:
- the source fragment for this match.
-
setSource
public void setSource(Fragment source)
Sets the source fragment for this match.- Parameters:
source- the new source fragment for this match.
-
getTarget
public Fragment getTarget()
Gets the target fragment for this match.- Returns:
- the target fragment for this match.
-
setTarget
public void setTarget(Fragment target)
Sets the target fragment for this match.- Parameters:
target- the new target fragment for this match.
-
getExtElements
public ExtElements getExtElements()
Description copied from interface:IWithExtElementsGets theExtElementsobject associated with this object. If none exists one is created.- Specified by:
getExtElementsin interfaceIWithExtElements- Returns:
- the
ExtElementsobject associated with this object. If none exists one is created.
-
hasExtElements
public boolean hasExtElements()
Description copied from interface:IWithExtElementsIndicates if there is aExtElementsobject associated with this object.- Specified by:
hasExtElementsin interfaceIWithExtElements- Returns:
- true if there is a
ExtElementsobject associated with this object, false otherwise.
-
setExtElements
public ExtElements setExtElements(ExtElements elements)
Description copied from interface:IWithExtElementsSets theExtElementsobject associated with this object.- Specified by:
setExtElementsin interfaceIWithExtElements- Parameters:
elements- theExtElementsobject associated with this object. If null, a newExtElementsobject is created.- Returns:
- the
ExtElementsobject associated with this object, never null.
-
isIdUsed
public boolean isIdUsed(String id)
Description copied from interface:IWithStore- Specified by:
isIdUsedin interfaceIWithStore- Parameters:
id- the id value to lookup.- Returns:
- true if the value is already used, false otherwise.
-
getSourceDir
public Directionality getSourceDir()
- Specified by:
getSourceDirin interfaceIWithStore
-
setSourceDir
public void setSourceDir(Directionality dir)
- Specified by:
setSourceDirin interfaceIWithStore
-
getTargetDir
public Directionality getTargetDir()
- Specified by:
getTargetDirin interfaceIWithStore
-
setTargetDir
public void setTargetDir(Directionality dir)
- Specified by:
setTargetDirin interfaceIWithStore
-
setExtAttributes
public void setExtAttributes(ExtAttributes attributes)
Description copied from interface:IWithExtAttributesSets theExtAttributesobject associated with this object.- Specified by:
setExtAttributesin interfaceIWithExtAttributes- Parameters:
attributes- theExtAttributesobject associated with this object. If null, a newExtAttributesobject is created.
-
getExtAttributes
public ExtAttributes getExtAttributes()
Description copied from interface:IWithExtAttributesGets theExtAttributesobject for the parent object. If none exists, one is created.- Specified by:
getExtAttributesin interfaceIWithExtAttributes- Returns:
- the
ExtAttributesobject for the parent object, never null.
-
hasExtAttribute
public boolean hasExtAttribute()
Description copied from interface:IWithExtAttributesIndicates if at least one extension attribute is present.- Specified by:
hasExtAttributein interfaceIWithExtAttributes- Returns:
- true if at least one extension attribute is present; false otherwise.
-
getExtAttributeValue
public String getExtAttributeValue(String namespaceURI, String localName)
Description copied from interface:IWithExtAttributesGets the value for a given extension attribute.- Specified by:
getExtAttributeValuein interfaceIWithExtAttributes- Parameters:
namespaceURI- the URI of the namespace for the attribute.localName- the name of the attribute.- Returns:
- the value of the extension attribute, or null if it does not exist.
-
getAnnotatorRef
public String getAnnotatorRef()
Gets the ITS annotator reference for this match.- Returns:
- the ITS annotator reference for this match (can be null).
-
setAnnoatorRef
public void setAnnoatorRef(String annotatorRef)
Sets the the ITS annotator reference for this match.- Parameters:
annotatorRef- the new ITS annotator reference (can be null).
-
getMTConfidence
public Double getMTConfidence()
Gets the ITS MT Confidence for this match. This value isgetMatchQuality()divided by 100.0.- Returns:
- the ITS MT Confidence for this match.
- See Also:
getMatchQuality()
-
setMTConfidence
public void setMTConfidence(Double mtConfidence)
Sets the ITS MT Confidence for this match. This value is the same as thegetMatchQuality()divided by 100.0.- Parameters:
mtConfidence- the new MT Confidence value to set (can be null).- See Also:
setMatchQuality(Double)
-
hasMetadata
public boolean hasMetadata()
Description copied from interface:IWithMetadataIndicates if the object has metadata.- Specified by:
hasMetadatain interfaceIWithMetadata- Returns:
- true if the object has metadata, false otherwise.
-
getMetadata
public Metadata getMetadata()
Description copied from interface:IWithMetadataGets theMetadataobject for the parent, creates an empty of if there is none.- Specified by:
getMetadatain interfaceIWithMetadata- Returns:
- the
Metadataobject for the parent (can be empty, but never null).
-
setMetadata
public void setMetadata(Metadata metadata)
Description copied from interface:IWithMetadatasets theMetadataobject for the parent.- Specified by:
setMetadatain interfaceIWithMetadata- Parameters:
metadata- the newMetadataobject for the parent.
-
-