Package com.gengoai.hermes.lexicon
Class SimpleWordList
- java.lang.Object
-
- com.gengoai.hermes.lexicon.SimpleWordList
-
- All Implemented Interfaces:
WordList
,Serializable
,Iterable<String>
public class SimpleWordList extends Object implements WordList, Serializable
Simple implementation of aWordList
backed by a HashSet- Author:
- David B. Bracewell
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SimpleWordList(@NonNull Collection<String> words)
Instantiates a new Simple word list.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(String string)
Is the String contained in the WordListIterator<String>
iterator()
static WordList
read(Resource resource)
Reads the word list from the given resource where each term is on its own line and "#" represents comments.int
size()
Number of words in the list-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
SimpleWordList
public SimpleWordList(@NonNull @NonNull Collection<String> words)
Instantiates a new Simple word list.- Parameters:
words
- the words
-
-
Method Detail
-
read
public static WordList read(Resource resource) throws IOException
Reads the word list from the given resource where each term is on its own line and "#" represents comments.
Note that convention states that if the first line of a word list is a comment stating "case-insensitive" then loading of that word list will result in all words being lower-cased.
- Parameters:
resource
- the resource- Returns:
- the word list
- Throws:
IOException
- the io exception
-
contains
public boolean contains(String string)
Description copied from interface:WordList
Is the String contained in the WordList
-
-