Class Madlib

java.lang.Object
madlibgeneration.Madlib

public class Madlib extends Object
The core object that contains the source text file from which its MadlibBlanker and MadlibFiller can blank words in the document and fill in the blanks with user-determined words
Author:
Adam Barnett
See Also:
  • Field Details

    • posMap

      private static final HashMap<String,String> posMap
      Used to pair the annotation identifiers from CoreNLP to clearer parts of speech. Example: CoreNLP tags nouns as "NN," so the program relays "NN" as "noun" to the rest of the program.
    • blanker

      private final MadlibBlanker blanker
      Utility class used to remove words from the source file and produce a new file with the blanked madlib
    • filler

      private final MadlibFiller filler
      Utility class to fill in the blanked madlib with user-chosen words and write it to a new file. This is referred to as a filled madlib.
    • annotatedText

      TextAnnotater annotatedText
      Converts CoreNLP tags with clearer part of speech identifiers. CoreNLP is a library that, in this program, is used to annotate each word with a "token" that contains the word and its associated part of speech
    • originalText

      String originalText
      Source text for madlib creation
    • blankedText

      String blankedText
      The original text with certain words deleted and replaced with text blocks containing their associated parts of speech
    • filledText

      String filledText
      Produced from the blankedText using user-prompted replacement words to replace the deleted words / part of speech blocks
    • posList

      List<String> posList
      The parts of speech associated with the removed words during the blankingn process. The CLI and MadlibFiller use these to prompt user replacement words and fill in the madlib
  • Constructor Details

    • Madlib

      public Madlib(String originalText, String blankedTextPath, int skipper) throws IOException, utility.exceptions.TextNotProcessedException
      Throws:
      IOException
      utility.exceptions.TextNotProcessedException
  • Method Details

    • removeMadlibifiables

      private void removeMadlibifiables(String filepath, int skipper) throws IOException, utility.exceptions.TextNotProcessedException
      Removes the skipper-th madlibifiable word with a part of speech in the posBlocks hashset. Madlibifiable word are tagged with parts of speech included in the posMap. Assigns the instance's posList returned by the helper method.
      Parameters:
      skipper - determines the frequency of madlib blanking (madlibification). Example: if skipper == 3, the method will clear every third madlibifiable word.
      Throws:
      IOException
      utility.exceptions.TextNotProcessedException
    • fillInMadlib

      public void fillInMadlib(Queue<String> replacementWords, String outFilename) throws IOException, utility.exceptions.TextNotProcessedException
      Primarily called by CLI to create a filled-in Madlib. Calls the instance's MadlibFiller to actually create and write to the file. Public method callable by CLI.
      Throws:
      IOException
      utility.exceptions.TextNotProcessedException
    • setOriginalText

      private void setOriginalText(String originalText)
    • getOriginalText

      private String getOriginalText()
    • setAnnotatedText

      private void setAnnotatedText(String text) throws utility.exceptions.TextNotProcessedException
      Throws:
      utility.exceptions.TextNotProcessedException
    • setBlankedText

      private void setBlankedText(String filepath) throws IOException, utility.exceptions.TextNotProcessedException
      Throws:
      IOException
      utility.exceptions.TextNotProcessedException
    • getPosList

      public List<String> getPosList()
    • getPosMap

      public static Map<String,String> getPosMap()