Package org.cis1200

Class ChatterBot

java.lang.Object
org.cis1200.ChatterBot

public class ChatterBot extends Object
  • Constructor Details

    • ChatterBot

      public ChatterBot(List<List<String>> trainingData)
      Parameters:
      trainingData - - cleaned data from which to construct the ChatterBot MarkovModel
  • Method Details

    • generatePost

      public String generatePost(NumberGenerator ng)
      Generates a single, well-formatted post by following a random walk through the MarkovModel. The path is given by the choices made by ng.

      A generated post consists of the sequence of tokens produced by the random walk, with spaces added after every token that is not itself followed by a punctuation token.

      For example, a walk through the MarkovChain of the illustrative example (see MarkovChain) might produce the following sequence of tokens:

           "a" "banana" "!" "and" "a" "chair"
       
      They would be concatenated with spaces (except before the "!" and at the end) to produce the post: "a banana! and a chair".

      NOTE: The StringBuilder class provides a useful way to append Strings and the method String.matches(String) can be used with PostParser.PUNCTUATION_TOKEN to determine whether a token is punctuation.

      Parameters:
      ng - a source of numbers for walking through the ChatterBot's MarkovChain
      Returns:
      the post generated by following that walk
    • generatePost

      public String generatePost()
      Generates a random post. This function is implemented for you.
      Returns:
      a randomly generated post
    • generateRandomPosts

      public List<String> generateRandomPosts(int numPosts)
      Generates a list containing a specified number of randomly generated posts. This function is implemented for you.
      Parameters:
      numPosts - number of posts to generate
      Returns:
      a list of random posts of length numPosts