Class 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 float calculateNgramDiceCoefficient​(String st1, String st2, org.apache.lucene.analysis.Analyzer analyzer)
      Calculate Dice's Coefficient for two strings with tokens as ngrams.
      static String getMimeType​(String fileName)  
      static void rearrangeCodes​(List<net.sf.okapi.common.resource.Code> codes, net.sf.okapi.common.resource.TextFragment targetTf)  
      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.
      static void removeCodes​(net.sf.okapi.common.resource.TextContainer tc)  
      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.
      static net.sf.okapi.common.resource.TextContainer safeGetTarget​(net.sf.okapi.common.resource.ITextUnit tu, net.sf.okapi.common.LocaleId trgLoc)  
      static void setAlOrigin​(net.sf.okapi.common.resource.ITextUnit tu, net.sf.okapi.common.LocaleId srcLoc, net.sf.okapi.common.LocaleId trgLoc)  
    • Constructor Detail

      • OkapiUtil

        public OkapiUtil()
    • 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 compare
        st2 - second string to compare
        analyzer - 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 unit
        removeTargetCodes - - 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 against
        targetTf - 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)
      • getMimeType

        public static String getMimeType​(String fileName)
      • rearrangeCodes

        public static void rearrangeCodes​(List<net.sf.okapi.common.resource.Code> codes,
                                          net.sf.okapi.common.resource.TextFragment targetTf)