|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.terrier.utility.StringComparator
public class StringComparator
Compares two strings which may have fixed length fields separated with a non word character (eg a dash), and a last field which corresponds to an integer. Two examples of such strings are XXX-XXX-012389 and XXX-XXX-1242 (XXX-XXX-1242 < XXX-XXX-012389 when compared using this comparator.
This class is primarily used for comparing docnos, especially for TREC like collections. The docnos in the DocumentIndex as expected to be sorted in an order compatible with this comparator.
Sorting Algorithm:
Field Summary | |
---|---|
static StringComparator |
Me
An instantiation of this class. |
Constructor Summary | |
---|---|
StringComparator()
|
Method Summary | |
---|---|
int |
compare(java.lang.String s1,
java.lang.String s2)
Compares two Strings, which have a number of fields that are separated by one or more non-alphanumeric characters. |
static int |
compareObjects(java.lang.Object o1,
java.lang.Object o2)
A static access method, to prevent having to instantiate a comparator This has the same parameters, return and implementation as compare(Object,Object) |
static int |
compareStrings(java.lang.String s1,
java.lang.String s2)
A static access method, to prevent having to instantiate a comparator This has the same parameters, return and implementation as compare(Object,Object) |
static void |
main(java.lang.String[] args)
Will display the comparator value between two strings from the command line arguments. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
---|
equals |
Field Detail |
---|
public static final StringComparator Me
Constructor Detail |
---|
public StringComparator()
Method Detail |
---|
public int compare(java.lang.String s1, java.lang.String s2)
compare
in interface java.util.Comparator<java.lang.String>
s1
- the first string object to compare.s2
- the second string object to compare.
public static int compareObjects(java.lang.Object o1, java.lang.Object o2)
public static int compareStrings(java.lang.String s1, java.lang.String s2)
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |