Class MadlibBlanker
java.lang.Object
madlibgeneration.MadlibBlanker
Processes Madlib through the "blanking" process, which takes the madlib's source text and blanks out certain words to be filled in later by the user.
- Author:
- Adam Barnett
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidjustWriteWord(edu.stanford.nlp.ling.CoreLabel token, BufferedWriter writer, boolean isFirstWord) Helper method for removeMadlibifiable() that writes each word to a file with a preceding space.removeMadlibifiables(String filepath, TextAnnotater annotatedText, int skipper) Removes the skipper-th word with a part of speech in the posBlocks hashsetprivate voidreplaceWordWithBlock(boolean isFirstWord, BufferedWriter writer, String replacementBlock) Like justWriteWord but handles Strings instead of tokens to print the part of speech returned by the part of speech map inside square brackets
-
Field Details
-
wordsToSkip
-
posMap
-
-
Constructor Details
-
MadlibBlanker
MadlibBlanker()
-
-
Method Details
-
removeMadlibifiables
public List<String> removeMadlibifiables(String filepath, TextAnnotater annotatedText, int skipper) throws IOException, utility.exceptions.TextNotProcessedException Removes the skipper-th word with a part of speech in the posBlocks hashset- Parameters:
skipper- determines the frequency of madlibification (replacement of word with part-of-speech text block). Example: if skipper == 3, removeMadlibifiables will clear every third madlibifiable word- Returns:
- returns List of parts of speech removed so user can replace the removed words when prompted by CLI
- Throws:
IOExceptionutility.exceptions.TextNotProcessedException- See Also:
-
replaceWordWithBlock
private void replaceWordWithBlock(boolean isFirstWord, BufferedWriter writer, String replacementBlock) throws IOException, utility.exceptions.InvalidPartOfSpeechException Like justWriteWord but handles Strings instead of tokens to print the part of speech returned by the part of speech map inside square brackets- Throws:
IOExceptionutility.exceptions.InvalidPartOfSpeechException
-
justWriteWord
private void justWriteWord(edu.stanford.nlp.ling.CoreLabel token, BufferedWriter writer, boolean isFirstWord) throws IOException Helper method for removeMadlibifiable() that writes each word to a file with a preceding space. Adds space before each word for simple avoidance of spaces before punctuation. Nothing is added to the punctuation character itself- Throws:
IOException
-