Class WordList

java.lang.Object
games.stendhal.common.parser.WordList

public final class WordList extends Object
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 Details

  • Constructor Details

    • WordList

      public WordList()
  • Method Details

    • getInstance

      public static WordList getInstance()
      Returns a reference to the global word list instance.
      Returns:
      WordList
    • read

      public void read(BufferedReader reader, List<String> comments) throws IOException
      Reads word list from reader object.
      Parameters:
      reader -
      comments -
      Throws:
      IOException
    • printWordType

      public void printWordType(PrintWriter writer, String type)
      Print all words of a given (main-)type.
      Parameters:
      writer -
      type -
    • trimWord

      public static String trimWord(String word)
      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

      public WordEntry find(String str)
      Find an entry for a given word.
      Parameters:
      str -
      Returns:
      WordEntry
    • plural

      public String plural(String word)
      Lookup the plural form of the given word from the word list.
      Parameters:
      word -
      Returns:
      plural string
    • singular

      public String singular(String word)
      Lookup the singular form of the given word from the word list.
      Parameters:
      word -
      Returns:
      singular string
    • registerSubjectName

      public void registerSubjectName(String name)
      Register a subject name to be recognized by the conversation parser.
      Parameters:
      name -
    • registerSubjectName

      public void registerSubjectName(String name, String typeString)
      Register a subject name to be recognized by the conversation parser.
      Parameters:
      name -
      typeString -
    • unregisterSubjectName

      public void unregisterSubjectName(String name)
      De-register a subject name.
      Parameters:
      name -
    • registerName

      public void registerName(String name, String typeString)
      Register an item or creature name to be recognized by the conversation parser.
      Parameters:
      name -
      typeString -
    • searchCompoundName

      public CompoundName searchCompoundName(AbstractList<Expression> expressions, int idx)
      Search for compound names.
      Parameters:
      expressions - list of expressions
      idx - start index of the expression list
      Returns:
      compound name or null
    • registerVerb

      public void registerVerb(String verb)
      Register a verb to be recognized by the conversation parser.
      Parameters:
      verb -
    • addNewWord

      public WordEntry addNewWord(String str)
      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