Package games.stendhal.common.parser
Class WordList
java.lang.Object
games.stendhal.common.parser.WordList
WordList stores a list of words recognized by the ConversationParser. Words
are categorised by type (noun, verb, adjective, preposition) and optionally
sub-types (animals, food, fluids, ...).
- Author:
- Martin Fuchs
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddNewWord(String str)
Add a new word to the list in order to remember it later.Find an entry for a given word.static WordList
Returns a reference to the global word list instance.int
Return number of word entries.Lookup the plural form of the given word from the word list.void
printWordType(PrintWriter writer, String type)
Print all words of a given (main-)type.void
read(BufferedReader reader, List<String> comments)
Reads word list from reader object.void
registerName(String name, String typeString)
Register an item or creature name to be recognized by the conversation parser.void
registerSubjectName(String name)
Register a subject name to be recognized by the conversation parser.void
registerSubjectName(String name, String typeString)
Register a subject name to be recognized by the conversation parser.void
registerVerb(String verb)
Register a verb to be recognized by the conversation parser.searchCompoundName(AbstractList<Expression> expressions, int idx)
Search for compound names.Lookup the singular form of the given word from the word list.static String
Transform the given word to lower case and trim special characters at beginning and end to use this normalized form as key in the word list.void
unregisterSubjectName(String name)
De-register a subject name.
-
Field Details
-
SUBJECT_NAME_DYNAMIC
- See Also:
- Constant Field Values
-
VERB_DYNAMIC
- See Also:
- Constant Field Values
-
WORDS_FILENAME
- See Also:
- Constant Field Values
-
-
Constructor Details
-
WordList
public WordList()
-
-
Method Details
-
getInstance
Returns a reference to the global word list instance.- Returns:
- WordList
-
read
Reads word list from reader object.- Parameters:
reader
-comments
-- Throws:
IOException
-
printWordType
Print all words of a given (main-)type.- Parameters:
writer
-type
-
-
trimWord
Transform the given word to lower case and trim special characters at beginning and end to use this normalized form as key in the word list.- Parameters:
word
-- Returns:
- the trimmed word
-
find
Find an entry for a given word.- Parameters:
str
-- Returns:
- WordEntry
-
plural
Lookup the plural form of the given word from the word list.- Parameters:
word
-- Returns:
- plural string
-
singular
Lookup the singular form of the given word from the word list.- Parameters:
word
-- Returns:
- singular string
-
registerSubjectName
Register a subject name to be recognized by the conversation parser.- Parameters:
name
-
-
registerSubjectName
Register a subject name to be recognized by the conversation parser.- Parameters:
name
-typeString
-
-
unregisterSubjectName
De-register a subject name.- Parameters:
name
-
-
registerName
Register an item or creature name to be recognized by the conversation parser.- Parameters:
name
-typeString
-
-
searchCompoundName
Search for compound names.- Parameters:
expressions
- list of expressionsidx
- start index of the expression list- Returns:
- compound name or null
-
registerVerb
Register a verb to be recognized by the conversation parser.- Parameters:
verb
-
-
addNewWord
Add a new word to the list in order to remember it later.- Parameters:
str
-- Returns:
- the added entry
-
getWordCount
public int getWordCount()Return number of word entries.- Returns:
- number of entries
-