Package org.cis1200

Class TwitterBot

java.lang.Object
org.cis1200.TwitterBot

public class TwitterBot extends Object
  • Constructor Details

    • TwitterBot

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

    • generateTweet

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

      A generated tweet 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 tweet: "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 TweetParser.PUNCTUATION_TOKEN to determine whether a token is punctuation.

      Parameters:
      ng - a source of numbers for walking through the TwitterBot's MarkovChain
      Returns:
      the tweet generated by following that walk
    • generateTweet

      public String generateTweet()
      Generates a random tweet. This function is implemented for you.
      Returns:
      a randomly generated tweet
    • generateRandomTweets

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