Package org.cis1200
Class TwitterBot
java.lang.Object
org.cis1200.TwitterBot
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerateRandomTweets
(int numTweets) Generates a list containing a specified number of randomly generated tweets.Generates a random tweet.Generates a single, well-formatted tweet by following a random walk through the MarkovModel.
-
Constructor Details
-
TwitterBot
- Parameters:
trainingData
- - cleaned data from which to construct the TwitterBot MarkovModel
-
-
Method Details
-
generateTweet
Generates a single, well-formatted tweet by following a random walk through the MarkovModel. The path is given by the choices made byng
.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 appendString
s and the methodString.matches(String)
can be used withTweetParser.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
Generates a random tweet. This function is implemented for you.- Returns:
- a randomly generated tweet
-
generateRandomTweets
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
-