Class SimpleLexicon

java.lang.Object
  extended by SimpleLexicon
All Implemented Interfaces:
ILexicon, java.lang.Iterable<java.lang.String>

public class SimpleLexicon
extends java.lang.Object
implements ILexicon

Simple Lexicon implementation simply storing words in a set. This makes finding WORD status fast, but PREFIX requires iterating over all the strings stored.


Constructor Summary
SimpleLexicon()
           
 
Method Summary
 java.util.Iterator<java.lang.String> iterator()
          Return an iterator over all words stored in the lexicon.
 void load(java.util.ArrayList<java.lang.String> list)
          Clear a lexicon and store all values read from the list for subsequent querying.
 void load(java.util.Scanner s)
          Clear a lexicon and store all values read from the scanner for subsequent querying.
 int size()
          Returns number of words stored in the lexicon (as from last call to load, for example).
 LexStatus wordStatus(java.lang.String s)
          Similar to wordStatus that takes a StringBuilder parameter, but works with a String.
 LexStatus wordStatus(java.lang.StringBuilder s)
          Returns value specifying whether is is in the lexicon: WORD, is the prefix of a word in the lexicon: PREFIX, or is not a prefix and not a word: NOT_WORD.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleLexicon

public SimpleLexicon()
Method Detail

load

public void load(java.util.Scanner s)
Description copied from interface: ILexicon
Clear a lexicon and store all values read from the scanner for subsequent querying.

Specified by:
load in interface ILexicon
Parameters:
s - is the source of words for the lexicon

load

public void load(java.util.ArrayList<java.lang.String> list)
Description copied from interface: ILexicon
Clear a lexicon and store all values read from the list for subsequent querying.

Specified by:
load in interface ILexicon
Parameters:
list - is the source of words for the lexicon

wordStatus

public LexStatus wordStatus(java.lang.String s)
Description copied from interface: ILexicon
Similar to wordStatus that takes a StringBuilder parameter, but works with a String.

Specified by:
wordStatus in interface ILexicon
Parameters:
s - is the string queried
Returns:
status of s as to how it appears in lexicon

iterator

public java.util.Iterator<java.lang.String> iterator()
Description copied from interface: ILexicon
Return an iterator over all words stored in the lexicon.

Specified by:
iterator in interface ILexicon
Specified by:
iterator in interface java.lang.Iterable<java.lang.String>
Returns:
an iterator over the words in the lexicon

size

public int size()
Description copied from interface: ILexicon
Returns number of words stored in the lexicon (as from last call to load, for example).

Specified by:
size in interface ILexicon
Returns:
number of words in the lexicon

wordStatus

public LexStatus wordStatus(java.lang.StringBuilder s)
Description copied from interface: ILexicon
Returns value specifying whether is is in the lexicon: WORD, is the prefix of a word in the lexicon: PREFIX, or is not a prefix and not a word: NOT_WORD. See LexStatus

Specified by:
wordStatus in interface ILexicon
Parameters:
s - represents the word/sequence queried
Returns:
status of s as to how it appears in lexicon