Package com.acumenvelocity.ath.common
Class OkapiUtil
- java.lang.Object
-
- com.acumenvelocity.ath.common.OkapiUtil
-
public class OkapiUtil extends Object
-
-
Constructor Summary
Constructors Constructor Description OkapiUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static floatcalculateNgramDiceCoefficient(String st1, String st2, org.apache.lucene.analysis.Analyzer analyzer)Calculate Dice's Coefficient for two strings with tokens as ngrams.static StringgetMimeType(String fileName)static voidrearrangeCodes(List<net.sf.okapi.common.resource.Code> codes, net.sf.okapi.common.resource.TextFragment targetTf)static voidremoveCodes(net.sf.okapi.common.resource.ITextUnit textUnit, boolean removeTargetCodes)Removes all inline tags in the source (or optionally the target) text unit resource.static voidremoveCodes(net.sf.okapi.common.resource.TextContainer tc)static voidremoveExtraCodes(List<net.sf.okapi.common.resource.Code> srcCodes, net.sf.okapi.common.resource.TextFragment targetTf)Removes codes from the target TextFragment that don't exist in the source codes list.static net.sf.okapi.common.resource.TextContainersafeGetTarget(net.sf.okapi.common.resource.ITextUnit tu, net.sf.okapi.common.LocaleId trgLoc)static voidsetAlOrigin(net.sf.okapi.common.resource.ITextUnit tu, net.sf.okapi.common.LocaleId srcLoc, net.sf.okapi.common.LocaleId trgLoc)
-
-
-
Method Detail
-
calculateNgramDiceCoefficient
public static float calculateNgramDiceCoefficient(String st1, String st2, org.apache.lucene.analysis.Analyzer analyzer)
Calculate Dice's Coefficient for two strings with tokens as ngrams.- Parameters:
st1- first string to comparest2- second string to compareanalyzer- n-gram analyzer- Returns:
- Dice's Coefficient as a float
-
safeGetTarget
public static net.sf.okapi.common.resource.TextContainer safeGetTarget(net.sf.okapi.common.resource.ITextUnit tu, net.sf.okapi.common.LocaleId trgLoc)
-
removeCodes
public static void removeCodes(net.sf.okapi.common.resource.ITextUnit textUnit, boolean removeTargetCodes)Removes all inline tags in the source (or optionally the target) text unit resource.- Parameters:
textUnit- the given text unitremoveTargetCodes- - remove target codes?
-
removeCodes
public static void removeCodes(net.sf.okapi.common.resource.TextContainer tc)
-
removeExtraCodes
public static void removeExtraCodes(List<net.sf.okapi.common.resource.Code> srcCodes, net.sf.okapi.common.resource.TextFragment targetTf)
Removes codes from the target TextFragment that don't exist in the source codes list. A code is considered to exist if there's a matching code in srcCodes with the same id and tagType pair.- Parameters:
srcCodes- the source list of codes to compare againsttargetTf- the target TextFragment from which to remove extra codes
-
setAlOrigin
public static void setAlOrigin(net.sf.okapi.common.resource.ITextUnit tu, net.sf.okapi.common.LocaleId srcLoc, net.sf.okapi.common.LocaleId trgLoc)
-
rearrangeCodes
public static void rearrangeCodes(List<net.sf.okapi.common.resource.Code> codes, net.sf.okapi.common.resource.TextFragment targetTf)
-
-