ir.utilities
Class MoreString

java.lang.Object
  extended by ir.utilities.MoreString

public class MoreString
extends java.lang.Object

A place to put some additional string functions


Constructor Summary
MoreString()
           
 
Method Summary
static int countPhrase(java.lang.String string, java.lang.String substring)
          Counts the number of times that a given substring appears in a string using matching as defined in startsWithPhrase
static int countPhrase(java.lang.String string, java.lang.String substring, int fromIndex)
          Counts the number of times that a given substring appears in a string using matching as defined in startsWithPhrase and starting in the string from fromIndex
static java.lang.String fileExtension(java.lang.String fileName)
           
static java.lang.String fileToString(java.lang.String fileName)
          Load the stopwords from file to the hashtable where they are indexed.
static int indexOfIgnoreCase(java.lang.String string, java.lang.String substring)
           
static int indexOfIgnoreCase(java.lang.String string, java.lang.String substring, int fromIndex)
           
static int indexOfPhrase(java.lang.String string, java.lang.String substring)
          Version of String method indexOf that treats all whitespace characters in substring as matching any "word boundary" and matches lowercase characters in the substring to either lower or uppercase in the string, but uppercase characters in the substring must match uppercase in the string
static int indexOfPhrase(java.lang.String string, java.lang.String substring, int fromIndex)
          Version of String method indexOf that treats all whitespace characters as equivalent and matches lowercase characters in the substring to either lower or uppercase in the string, but uppercase characters in the substring must match uppercase in the string
static boolean isWordBoundary(char x)
          Returns true iff character is in a specific set considered to mark a word boundary
static void main(java.lang.String[] args)
           
static java.lang.String padTo(java.lang.String string, int length)
          Pad a string with blanks on the right to make it the specified length
static java.lang.String padTo(java.lang.String string, int length, char ch)
          Pad a string with a specific char on the right to make it the specified length
static java.lang.String padToLeft(double x, int length)
          Convert a double to a string and pad with blanks on the left to make it the specified length
static java.lang.String padToLeft(int x, int length)
          Convert an int to a string and pad with blanks on the left to make it the specified length
static java.lang.String padToLeft(java.lang.String string, int length)
          Pad a string with blanks on the left to make it the specified length
static java.lang.String padToLeft(java.lang.String string, int length, char ch)
          Pad a string with a specific char on the left to make it the specified length
static java.lang.String padWithZeros(double x, int length)
           
static java.lang.String padWithZeros(int x, int length)
           
static java.util.ArrayList<java.lang.String> segment(java.lang.String string, char ch)
          Segment a string into substrings by breaking at occurences of the given character and returning a list of segments
static java.lang.String[] segmentToArray(java.lang.String string, char ch)
          Segment a string into substrings by breaking at occurrences of the given character and returning an array of all the segments, in order
static boolean startsWithIgnoreCase(java.lang.String string, java.lang.String substring)
           
static boolean startsWithIgnoreCase(java.lang.String string, java.lang.String substring, int fromIndex)
           
static boolean startsWithPhrase(java.lang.String string, java.lang.String substring)
          Version of String method startsWith that treats all whitespace characters in substring as matching any "word boundary" and matches lowercase characters in the substring to either lower or uppercase in the string, but uppercase characters in the substring must match uppercase in the string
static boolean startsWithPhrase(java.lang.String string, java.lang.String substring, int fromIndex)
          Version of String method startsWith that treats all whitespace characters in substring as matching any "word boundary" and matches lowercase characters in the substring to either lower or uppercase in the string, but uppercase characters in the substring must match uppercase in the string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MoreString

public MoreString()
Method Detail

padTo

public static java.lang.String padTo(java.lang.String string,
                                     int length,
                                     char ch)
Pad a string with a specific char on the right to make it the specified length


padTo

public static java.lang.String padTo(java.lang.String string,
                                     int length)
Pad a string with blanks on the right to make it the specified length


padToLeft

public static java.lang.String padToLeft(java.lang.String string,
                                         int length,
                                         char ch)
Pad a string with a specific char on the left to make it the specified length


padToLeft

public static java.lang.String padToLeft(java.lang.String string,
                                         int length)
Pad a string with blanks on the left to make it the specified length


padToLeft

public static java.lang.String padToLeft(double x,
                                         int length)
Convert a double to a string and pad with blanks on the left to make it the specified length


padToLeft

public static java.lang.String padToLeft(int x,
                                         int length)
Convert an int to a string and pad with blanks on the left to make it the specified length


padWithZeros

public static java.lang.String padWithZeros(int x,
                                            int length)

padWithZeros

public static java.lang.String padWithZeros(double x,
                                            int length)

segment

public static java.util.ArrayList<java.lang.String> segment(java.lang.String string,
                                                            char ch)
Segment a string into substrings by breaking at occurences of the given character and returning a list of segments


segmentToArray

public static java.lang.String[] segmentToArray(java.lang.String string,
                                                char ch)
Segment a string into substrings by breaking at occurrences of the given character and returning an array of all the segments, in order


indexOfIgnoreCase

public static int indexOfIgnoreCase(java.lang.String string,
                                    java.lang.String substring,
                                    int fromIndex)

indexOfIgnoreCase

public static int indexOfIgnoreCase(java.lang.String string,
                                    java.lang.String substring)

startsWithIgnoreCase

public static boolean startsWithIgnoreCase(java.lang.String string,
                                           java.lang.String substring,
                                           int fromIndex)

startsWithIgnoreCase

public static boolean startsWithIgnoreCase(java.lang.String string,
                                           java.lang.String substring)

indexOfPhrase

public static int indexOfPhrase(java.lang.String string,
                                java.lang.String substring,
                                int fromIndex)
Version of String method indexOf that treats all whitespace characters as equivalent and matches lowercase characters in the substring to either lower or uppercase in the string, but uppercase characters in the substring must match uppercase in the string


indexOfPhrase

public static int indexOfPhrase(java.lang.String string,
                                java.lang.String substring)
Version of String method indexOf that treats all whitespace characters in substring as matching any "word boundary" and matches lowercase characters in the substring to either lower or uppercase in the string, but uppercase characters in the substring must match uppercase in the string


startsWithPhrase

public static boolean startsWithPhrase(java.lang.String string,
                                       java.lang.String substring,
                                       int fromIndex)
Version of String method startsWith that treats all whitespace characters in substring as matching any "word boundary" and matches lowercase characters in the substring to either lower or uppercase in the string, but uppercase characters in the substring must match uppercase in the string


startsWithPhrase

public static boolean startsWithPhrase(java.lang.String string,
                                       java.lang.String substring)
Version of String method startsWith that treats all whitespace characters in substring as matching any "word boundary" and matches lowercase characters in the substring to either lower or uppercase in the string, but uppercase characters in the substring must match uppercase in the string


isWordBoundary

public static boolean isWordBoundary(char x)
Returns true iff character is in a specific set considered to mark a word boundary


countPhrase

public static int countPhrase(java.lang.String string,
                              java.lang.String substring,
                              int fromIndex)
Counts the number of times that a given substring appears in a string using matching as defined in startsWithPhrase and starting in the string from fromIndex


countPhrase

public static int countPhrase(java.lang.String string,
                              java.lang.String substring)
Counts the number of times that a given substring appears in a string using matching as defined in startsWithPhrase


fileExtension

public static java.lang.String fileExtension(java.lang.String fileName)

fileToString

public static java.lang.String fileToString(java.lang.String fileName)
Load the stopwords from file to the hashtable where they are indexed.


main

public static void main(java.lang.String[] args)