Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.crosswire.jsword.book
Class SentenceUtil

    java.lang.Object
      org.crosswire.jsword.book.SentenceUtil

    public final class SentenceUtil

extends Object

The SentenceUtil class provide utility functions for the various Books. It is not designed to be used outside of the book package, so using it outside of these bounds is at your own risk.

Author:
  Joe Walker [joe at eireneh dot com]
See Also:
  `for license details. The copyright to this program is held by it's authors.`

Constructor Summary
`private` | `SentenceUtil()` Ensure we can not be instantiated

Method Summary
`static int` | `firstLetter(String word)` Where is the first letter in this word
`static String[]` | `getWords(String aSentence)` From a sentence get a list of words (in original order) without any punctuation, and all in lower case.
`static int` | `lastLetter(String word)` Where is the last letter in this word
`static String[]` | `stripPunctuation(String[] words)` From a sentence get a list of words (in original order) without any punctuation, and all in lower case.
`static String` | `stripPunctuationWord(String word)` Remove the punctuation from the ends of the word
`static String[]` | `stripWords(String[] words)` From a sentence get a list of words (in original order) without any punctuation, and all in lower case.
`static String` | `stripWords(String first, String last)` Remove the punctuation from the ends of the word.
`static String[]` | `tokenize(String sentence)` Take a string and tokenize it using " " and "--" as delimiters into an Array of Strings.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SentenceUtil

    private SentenceUtil()

  Ensure we can not be instantiated

Method Detail

### tokenize

    public static String[] tokenize(String sentence)

  Take a string and tokenize it using " " and "--" as delimiters into an Array of Strings. There is a question mark over what to do with initial spaces. This algorithm discards them, I'm not sure if this is the right thing to do.

  Parameters:
    `sentence` - The string to parse.
  Returns:
    The string array

### stripPunctuation

    public static String[] stripPunctuation(String[] words)

  From a sentence get a list of words (in original order) without any punctuation, and all in lower case.

  Parameters:
    `words` - Words with punctuation
  Returns:
    Words without punctuation

### stripWords

    public static String[] stripWords(String[] words)

  From a sentence get a list of words (in original order) without any punctuation, and all in lower case.

  Parameters:
    `words` - Words with punctuation
  Returns:
    Punctuation without words

### getWords

    public static String[] getWords(String aSentence)

  From a sentence get a list of words (in original order) without any punctuation, and all in lower case.

  Parameters:
    `aSentence` - The string to parse.
  Returns:
    The words split up as an array

### stripPunctuationWord

    public static String stripPunctuationWord(String word)

  Remove the punctuation from the ends of the word

  Parameters:
    `word` - Word with punctuation
  Returns:
    Word without punctuation

### stripWords

    public static String stripWords(String first,
                                    String last)

  Remove the punctuation from the ends of the word. The special case is that if the first word ends "--" and the last word has no punctuation at the beginning, then the answer is "--" and not "-- ". We miss out the space because "--" is a special separator.

  Parameters:
    `first` - The word to grab the punctuation from the end of
    `last` - The word to grab the punctuation from the start of
  Returns:
    The end of the first, a space, and the end of the first

### firstLetter

    public static int firstLetter(String word)

  Where is the first letter in this word

  Parameters:
    `word` - The word to search for letters
  Returns:
    The offset of the first letter

### lastLetter

    public static int lastLetter(String word)

  Where is the last letter in this word

  Parameters:
    `word` - The word to search for letters
  Returns:
    The offset of the last letter

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Copyright ¨ 2003-2007
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD