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