Class Vocabulary
java.lang.Object
Vocabulary
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new vocabulary object with empty lists of starting words and no word pairs. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStartingWord(String word) Add a starting word occurrence.voidaddWordPair(String lastWord, String word) Add a word pair from a document.intNumber of word occurrences that can start a sentence.intNumber of word pairs (preceding-word, following-word) that have been entered.Get a list of all known starting words, in the order added.getWordsThatCanFollow(String lastWord) Returns a list of all words that are known to have followed lastWord, in the order added.
-
Constructor Details
-
Vocabulary
public Vocabulary()Create a new vocabulary object with empty lists of starting words and no word pairs.
-
-
Method Details
-
addStartingWord
Add a starting word occurrence. Duplicate words are permitted and are retained, not discarded.- Parameters:
word- a word that can begin a new sentence
-
addWordPair
Add a word pair from a document. Duplicate pairs are permitted and are retained, not discarded.- Parameters:
lastWord- a word that can precede anotherword- a word that can follow lastWord
-
getNumStartingWords
public int getNumStartingWords()Number of word occurrences that can start a sentence.- Returns:
- number of sentence-starting words
-
getNumWordPairs
public int getNumWordPairs()Number of word pairs (preceding-word, following-word) that have been entered.- Returns:
- number of work pairs
-
getStartingWords
Get a list of all known starting words, in the order added. If no starting words have been added, returns a list of length 0.- Returns:
- list of starting words
-
getWordsThatCanFollow
Returns a list of all words that are known to have followed lastWord, in the order added. If no such words exist, returns a list of length 0.
-