|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectWordPredict
public class WordPredict
Class and demo program for word prediction and word completion.
Invocation:
PROMPT>java WordPredict file n where file = a word+freq dictionary file n = maximum number of predicted wordsHere is an example dialogue: (User input is underlined)
PROMPT>java WordPredict d1-wordfreq.txt 10 Dictionary contains 64566 words Most frequent 10 words... the of and to a in that it is was Enter word or word stem... t the to that this they their there them time two th the that this they their there them then these than the the they their there them then these themselves therefore theory psy psychological psychology psychiatric psychologists ja january james japan jack japanese jane jacket jackson jan jazz ^z
Constructor Summary | |
---|---|
WordPredict(java.lang.String wordFreqFile)
Construct a WordPredict object. |
Method Summary | |
---|---|
int |
getSizeOfDictionary()
Return the size of the dictionary. |
java.lang.String[] |
getWords(java.lang.String stem,
int max)
Get an array of words completing the specified word stem. |
static void |
main(java.lang.String[] args)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WordPredict(java.lang.String wordFreqFile) throws java.io.IOException
A WordPredict object is used for word completion (given a word stem) or word prediction (given an empty word stem).
wordFreqFile
- a word-frequency dictionary file, for example,
d1-wordfreq.txt.
java.io.IOException
Method Detail |
---|
public static void main(java.lang.String[] args) throws java.io.IOException
java.io.IOException
public java.lang.String[] getWords(java.lang.String stem, int max)
This method includes "discount" word prediction. If the word stem is
an empty string, the
list is simply the
Note that the array may be less than
max most frequent words in the
dictionary.
max
, depending on the
word stem and the dictionary.
stem
- a word stemmax
- maximum number of words to return
null
if there are no matches or if
stem
is null
public int getSizeOfDictionary()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |