Package edu.upf.taln.dri.common.util
Class Util
- java.lang.Object
-
- edu.upf.taln.dri.common.util.Util
-
public class Util extends Object
Collection of comparison and sotr utility methods.
-
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
computeLevenshteinDistance(CharSequence lhs, CharSequence rhs)
Levenshtein Distance computationstatic double
computeMetricLCS(String lhs, String rhs)
Compute the Metric Longest Common Subsequence over normalized strings Equal to 0 means that the strings are identicalstatic Set<String>
fromListIntToSetString(List<Integer> inputList)
Convert a list of integer in a list of stringstatic boolean
intCompare(Integer int1, Integer int2)
Compare two Integersstatic void
main(String[] args)
static void
notifyException(String localMsg, Exception e, org.apache.log4j.Logger l)
Notify exceptionstatic <K,V extends Comparable<? super V>>
Map<K,V>sortByValueDec(Map<K,V> map)
Sort a map by decreasing valuestatic <K,V extends Comparable<? super V>>
Map<K,V>sortByValueInc(Map<K,V> map)
Sort a map by increasing valuestatic boolean
strCompare(String str1, String str2)
Compare two string - true if both not null and equalstatic boolean
strCompareCI(String str1, String str2)
Compare two string case insensitive - true if both not null and equalstatic boolean
strCompareTrimmed(String str1, String str2)
Compare two string case insensitive - true if both not null and equalstatic boolean
strCompareTrimmedCI(String str1, String str2)
Compare two string case insensitive - true if both not null and equal
-
-
-
Method Detail
-
strCompare
public static boolean strCompare(String str1, String str2)
Compare two string - true if both not null and equal- Returns:
-
strCompareCI
public static boolean strCompareCI(String str1, String str2)
Compare two string case insensitive - true if both not null and equal- Returns:
-
strCompareTrimmed
public static boolean strCompareTrimmed(String str1, String str2)
Compare two string case insensitive - true if both not null and equal- Returns:
-
strCompareTrimmedCI
public static boolean strCompareTrimmedCI(String str1, String str2)
Compare two string case insensitive - true if both not null and equal- Returns:
-
intCompare
public static boolean intCompare(Integer int1, Integer int2)
Compare two Integers- Parameters:
int1
-int2
-- Returns:
-
notifyException
public static void notifyException(String localMsg, Exception e, org.apache.log4j.Logger l)
Notify exception- Parameters:
localMsg
-e
-l
-
-
sortByValueInc
public static <K,V extends Comparable<? super V>> Map<K,V> sortByValueInc(Map<K,V> map)
Sort a map by increasing value- Parameters:
map
-- Returns:
-
sortByValueDec
public static <K,V extends Comparable<? super V>> Map<K,V> sortByValueDec(Map<K,V> map)
Sort a map by decreasing value- Parameters:
map
-- Returns:
-
computeLevenshteinDistance
public static int computeLevenshteinDistance(CharSequence lhs, CharSequence rhs)
Levenshtein Distance computation- Parameters:
lhs
-rhs
-- Returns:
-
computeMetricLCS
public static double computeMetricLCS(String lhs, String rhs)
Compute the Metric Longest Common Subsequence over normalized strings Equal to 0 means that the strings are identical- Parameters:
lhs
-rhs
-- Returns:
-
fromListIntToSetString
public static Set<String> fromListIntToSetString(List<Integer> inputList)
Convert a list of integer in a list of string- Parameters:
inputList
-- Returns:
-
main
public static void main(String[] args)
-
-