edu.northwestern.at.morphadorner

## Class MorphAdorner

- java.lang.Object
- - edu.northwestern.at.morphadorner.MorphAdorner

-     public class MorphAdorner
      extends java.lang.Object

  Morphological Adorner.

  Given an input text, the morphological adorner adorns each word with morphological information such as part of speech, lemma and standardized spelling.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `Abbreviations` | `abbreviations` Abbreviations.
    `int` | `defaultKWICWidth` Number of chararacters in a KWIC line.
    `TaggedStrings` | `extraWords` Extra words.
    `java.lang.String` | `extraWordsFileName` Extra words file.
    `java.lang.String` | `latinWordsFileName` Latin words file.
    `java.lang.String` | `lemmaSeparator`
    `Lemmatizer` | `lemmatizer` Lemmatizer.
    `Abbreviations` | `mainAbbreviations` Main text abbreviations.
    `MorphAdornerLogger` | `morphAdornerLogger` MorphAdorner logger.
    `MorphAdornerSettings` | `morphAdornerSettings` MorphAdorner settings.
    `Names` | `names` Proper names.
    `NameStandardizer` | `nameStandardizer` Proper name standardizer.
    `PartOfSpeechGuesser` | `partOfSpeechGuesser` Part of speech guesser.
    `PartOfSpeechTags` | `partOfSpeechTags` Part of speech tags.
    `PartOfSpeechRetagger` | `retagger` Part of speech retagger.
    `Abbreviations` | `sideAbbreviations` Side text abbreviations.
    `SpellingMapper` | `spellingMapper` Spelling mapper.
    `SpellingStandardizer` | `spellingStandardizer` Spelling standardizer.
    `WordTokenizer` | `spellingTokenizer` Spelling tokenizer for lemmatization.
    `protected static java.util.Map<java.lang.String,MorphAdorner>` | `storedAdorners` Stores initialized MorphAdorner objects for reuse.
    `Lexicon` | `suffixLexicon` Suffix lexicon.
    `TEITagClassifier` | `tagClassifier` Tag classifier.
    `PartOfSpeechTagger` | `tagger` Part of speech tagger.
    `java.lang.String` | `tagSeparator` Part of speech tag separator.
    `MorphAdornerSettings` | `tokenizationSettings` MorphAdorner settings for XML tokenization.
    `TransitionMatrix` | `transitionMatrix` Transition matrix.
    `Lexicon` | `wordLexicon` Word lexicon.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MorphAdorner()` Create empty MorphAdorner object.
    `MorphAdorner(java.lang.String[] args)` Create MorphAdorner object.
    `MorphAdorner(java.lang.String[] args, java.lang.String logConfiguration, java.lang.String logDirectory)` Create MorphAdorner object.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAbbreviations(Abbreviations abbreviations, java.lang.String abbreviationsURL, java.lang.String loadedMessage)` Add abbreviations.
    `AdornedWordOutputter` | `adornFile(java.lang.String fileName)` Perform word adornment processes for a single input file.
    `AdornedWordOutputter` | `adornText(java.lang.String textToAdorn, java.net.URL outputURL)` Perform word adornment processes for a single input file.
    `void` | `adornXML(java.lang.String inputFileName, boolean tokenizeOnly)` Adorn XML file.
    `static MorphAdorner` | `createAdorner(java.lang.String adornerName, boolean replaceAdorner, java.lang.String[] adornerArgs, java.lang.String adornerLogConfig, java.lang.String adornerLogDirectory)` Create a Morphological Adorner.
    `static MorphAdorner` | `createAndRunAdorner(java.lang.String adornerName, boolean replaceAdorner, java.lang.String[] adornerArgs, java.lang.String adornerLogConfig, java.lang.String adornerLogDirectory, java.lang.String outputDirectory, java.lang.String[] filesToAdorn, boolean tokenizeOnly)` Create and run a Morphological Adorner.
    `boolean` | `doesOutputFileNameExist(java.lang.String inputFileName)` Check if output file name for adorned output already exists.
    `void` | `finalize()` Finalize.
    `protected void` | `fixSideWords(org.w3c.dom.Document document, Abbreviations sideAbbreviations)` Fix abbreviations in side text.
    `java.lang.String` | `getOutputFileName(java.lang.String inputFileName)` Generate output file name for adorned output.
    `static java.util.Map<java.lang.String,MorphAdorner>` | `getStoredAdorners()` Get map of stored adorners.
    `protected void` | `initializeAdornment()` Initialize adornment classes.
    `protected boolean` | `inSideText(org.w3c.dom.Node element)` Is element in side text.
    `static void` | `main(java.lang.String[] args)` Create and run a Morphological Adorner.
    `protected static void` | `mergeXML(TextInputter inputter, java.lang.String xmlFileName)` Merge xml fragments into one xml file.
    `protected void` | `printWords(org.w3c.dom.Document document)` Print words in DOM document.
    `void` | `processInputFiles()` Process list of files containing text to adorn.
    `void` | `processInputFiles(boolean xmlTokenizeOnly)` Process list of files containing text to adorn.
    `void` | `readorn(java.lang.String inputFileName)` Readorn adorned XML file.
    `static MorphAdorner` | `runAdorner(MorphAdorner adorner, java.lang.String outputDirectory, java.lang.String[] filesToAdorn, boolean tokenizeOnly)` Run a Morphological Adorner.
    `static MorphAdorner` | `runAdorner(java.lang.String adornerName, java.lang.String outputDirectory, java.lang.String[] filesToAdorn, boolean tokenizeOnly)` Run a Morphological Adorner.
    `static void` | `setStoredAdorners(java.util.Map<java.lang.String,MorphAdorner> storedAdorners)` Set map of stored adorners.
    `void` | `updateAdornedSentence(java.util.List<ExtendedAdornedWord> sentence, java.util.Set<java.lang.String> regIDSet)` Adorn a list of sentences containing adorned words.
    `void` | `updateAdornedSentences(java.util.List<java.util.List<ExtendedAdornedWord>> sentences, java.util.Set<java.lang.String> regIDSet)` Adorn a list of sentences containing adorned words.
    `protected void` | `updateSplitWordAdornments(ExtendedAdornedWordFilter wordFilter)` Update adornments for split words.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### storedAdorners

          protected static java.util.Map<java.lang.String,MorphAdorner> storedAdorners

      Stores initialized MorphAdorner objects for reuse.

    - #### defaultKWICWidth

          public int defaultKWICWidth

      Number of chararacters in a KWIC line.

    - #### latinWordsFileName

          public java.lang.String latinWordsFileName

      Latin words file.

    - #### extraWordsFileName

          public java.lang.String extraWordsFileName

      Extra words file.

    - #### extraWords

          public TaggedStrings extraWords

      Extra words.

    - #### spellingTokenizer

          public WordTokenizer spellingTokenizer

      Spelling tokenizer for lemmatization.

    - #### partOfSpeechTags

          public PartOfSpeechTags partOfSpeechTags

      Part of speech tags.

    - #### tagger

          public PartOfSpeechTagger tagger

      Part of speech tagger.

    - #### retagger

          public PartOfSpeechRetagger retagger

      Part of speech retagger.

    - #### wordLexicon

          public Lexicon wordLexicon

      Word lexicon.

    - #### partOfSpeechGuesser

          public PartOfSpeechGuesser partOfSpeechGuesser

      Part of speech guesser.

    - #### suffixLexicon

          public Lexicon suffixLexicon

      Suffix lexicon.

    - #### transitionMatrix

          public TransitionMatrix transitionMatrix

      Transition matrix.

    - #### spellingStandardizer

          public SpellingStandardizer spellingStandardizer

      Spelling standardizer.

    - #### spellingMapper

          public SpellingMapper spellingMapper

      Spelling mapper.

    - #### nameStandardizer

          public NameStandardizer nameStandardizer

      Proper name standardizer.

    - #### lemmatizer

          public Lemmatizer lemmatizer

      Lemmatizer.

    - #### names

          public Names names

      Proper names.

    - #### abbreviations

          public Abbreviations abbreviations

      Abbreviations.

    - #### mainAbbreviations

          public Abbreviations mainAbbreviations

      Main text abbreviations.

    - #### sideAbbreviations

          public Abbreviations sideAbbreviations

      Side text abbreviations.

    - #### tagSeparator

          public java.lang.String tagSeparator

      Part of speech tag separator.

    - #### lemmaSeparator

          public java.lang.String lemmaSeparator

    - #### morphAdornerLogger

          public MorphAdornerLogger morphAdornerLogger

      MorphAdorner logger.

    - #### morphAdornerSettings

          public MorphAdornerSettings morphAdornerSettings

      MorphAdorner settings.

    - #### tokenizationSettings

          public MorphAdornerSettings tokenizationSettings

      MorphAdorner settings for XML tokenization.

    - #### tagClassifier

          public TEITagClassifier tagClassifier

      Tag classifier.

  - ### Constructor Detail

    - #### MorphAdorner

          public MorphAdorner()

      Create empty MorphAdorner object.

    - #### MorphAdorner

          public MorphAdorner(java.lang.String[] args,
                      java.lang.String logConfiguration,
                      java.lang.String logDirectory)

      Create MorphAdorner object.
      Parameters:
        `args` - Command line parameters.
        `logConfiguration` - Log file configuration.
        `logDirectory` - Log file directory.

    - #### MorphAdorner

          public MorphAdorner(java.lang.String[] args)

      Create MorphAdorner object.
      Parameters:
        `args` - Parameters.

  - ### Method Detail

    - #### getStoredAdorners

          public static java.util.Map<java.lang.String,MorphAdorner> getStoredAdorners()

      Get map of stored adorners.
      Returns:
        Map from names to adorner instances.

    - #### setStoredAdorners

          public static void setStoredAdorners(java.util.Map<java.lang.String,MorphAdorner> storedAdorners)

      Set map of stored adorners.
      Parameters:
        `storedAdorners` - Map from names to adorner instances.

    - #### initializeAdornment

          protected void initializeAdornment()

      Initialize adornment classes.

    - #### processInputFiles

          public void processInputFiles(boolean xmlTokenizeOnly)

      Process list of files containing text to adorn.
      Parameters:
        `xmlTokenizeOnly` - Only tokenize XML files.

    - #### processInputFiles

          public void processInputFiles()

      Process list of files containing text to adorn.

    - #### adornXML

          public void adornXML(java.lang.String inputFileName,
                      boolean tokenizeOnly)
                        throws java.lang.Exception

      Adorn XML file.
      Parameters:
        `inputFileName` - File name of XML file to adorn.
        `tokenizeOnly` - Only tokenize.
      Throws:
        `java.lang.Exception` - For variety of errors.

    - #### printWords

          protected void printWords(org.w3c.dom.Document document)

      Print words in DOM document.
      Parameters:
        `document` - The DOM document containing words to print.

        The text of and elements is printed.

    - #### fixSideWords

          protected void fixSideWords(org.w3c.dom.Document document,
                          Abbreviations sideAbbreviations)

      Fix abbreviations in side text.
      Parameters:
        `document` - DOM document containing words to fix.
        `sideAbbreviations` - Abbreviations list for side text.

    - #### inSideText

          protected boolean inSideText(org.w3c.dom.Node element)

      Is element in side text.
      Parameters:
        `element` - Element.
      Returns:
        True for side text, false otherwise.

    - #### getOutputFileName

          public java.lang.String getOutputFileName(java.lang.String inputFileName)
                                             throws java.io.IOException

      Generate output file name for adorned output.
      Parameters:
        `inputFileName` - The input file name.
      Returns:
        The output file name.
      Throws:
        `java.io.IOException` - if output directory cannot be created.

    - #### doesOutputFileNameExist

          public boolean doesOutputFileNameExist(java.lang.String inputFileName)

      Check if output file name for adorned output already exists.
      Parameters:
        `inputFileName` - The input file name.
      Returns:
        True if output file name already exists.

    - #### adornFile

          public AdornedWordOutputter adornFile(java.lang.String fileName)
                                         throws java.io.IOException

      Perform word adornment processes for a single input file.
      Parameters:
        `fileName` - Input file name.
      Throws:
        `java.lang.Exception` - if an error occurs.
        `java.io.IOException`

    - #### adornText

          public AdornedWordOutputter adornText(java.lang.String textToAdorn,
                                       java.net.URL outputURL)
                                         throws java.io.IOException

      Perform word adornment processes for a single input file.
      Parameters:
        `textToAdorn` - Text to adorn.
        `outputURL` - URL for output.
      Throws:
        `java.lang.Exception` - if an error occurs.
        `java.io.IOException`

    - #### readorn

          public void readorn(java.lang.String inputFileName)
                       throws org.xml.sax.SAXException,
                              java.io.IOException,
                              java.io.FileNotFoundException

      Readorn adorned XML file.
      Parameters:
        `inputFileName` - Input XML file name.
      Throws:
        `org.xml.sax.SAXException`
        `java.io.IOException`
        `java.io.FileNotFoundException`

    - #### updateAdornedSentences

          public void updateAdornedSentences(java.util.List<java.util.List<ExtendedAdornedWord>> sentences,
                                    java.util.Set<java.lang.String> regIDSet)

      Adorn a list of sentences containing adorned words.
      Parameters:
        `sentences` - Previously adorned sentences to readorn.
        `regIDSet` - Word IDs of words with preset standard spellings.

    - #### updateSplitWordAdornments

          protected void updateSplitWordAdornments(ExtendedAdornedWordFilter wordFilter)

      Update adornments for split words.
      Parameters:
        `wordFilter` - ExtendedAdornedWordFilter with words to update.

    - #### updateAdornedSentence

          public void updateAdornedSentence(java.util.List<ExtendedAdornedWord> sentence,
                                   java.util.Set<java.lang.String> regIDSet)

      Adorn a list of sentences containing adorned words.
      Parameters:
        `sentence` - Previously adorned sentence to update.
        `regIDSet` - Word IDs of words with preset standard spellings.

    - #### addAbbreviations

          public void addAbbreviations(Abbreviations abbreviations,
                              java.lang.String abbreviationsURL,
                              java.lang.String loadedMessage)

      Add abbreviations.
      Parameters:
        `abbreviationsURL` - Abbreviations URL.
        `loadedMessage` - Message to display when words loaded.

    - #### mergeXML

          protected static void mergeXML(TextInputter inputter,
                      java.lang.String xmlFileName)

      Merge xml fragments into one xml file.

    - #### main

          public static void main(java.lang.String[] args)

      Create and run a Morphological Adorner.
      Parameters:
        `args` - Program arguments.

    - #### createAdorner

          public static MorphAdorner createAdorner(java.lang.String adornerName,
                                   boolean replaceAdorner,
                                   java.lang.String[] adornerArgs,
                                   java.lang.String adornerLogConfig,
                                   java.lang.String adornerLogDirectory)

      Create a Morphological Adorner.
      Parameters:
        `adornerName` - Name for this adorner.
        `replaceAdorner` - Replace existing adorner.
        `adornerArgs` - Adorner arguments.
        `adornerLogConfig` - Adorner log file configuration.
        `adornerLogDirectory` - Adorner log directory.
      Returns:
        The adorner.

    - #### runAdorner

          public static MorphAdorner runAdorner(MorphAdorner adorner,
                                java.lang.String outputDirectory,
                                java.lang.String[] filesToAdorn,
                                boolean tokenizeOnly)

      Run a Morphological Adorner.
      Parameters:
        `adorner` - The adorner to run.
        `outputDirectory` - Adorned files output directory.
        `filesToAdorn` - File names to adorn.
        `tokenizeOnly` - Only tokenize XML files.
      Returns:
        The adorner used.

        If the adorner specified is null, no processing is performed, and null is returned as the adorned used.

    - #### runAdorner

          public static MorphAdorner runAdorner(java.lang.String adornerName,
                                java.lang.String outputDirectory,
                                java.lang.String[] filesToAdorn,
                                boolean tokenizeOnly)

      Run a Morphological Adorner.
      Parameters:
        `adornerName` - Name for this adorner.
        `outputDirectory` - Adorned files output directory.
        `filesToAdorn` - File names to adorn.
        `tokenizeOnly` - Only tokenize XML files.
      Returns:
        The adorner used. Null if not found.

        If the requested adorner was not found, no processing is performed, and null is return as the adorner used.

    - #### createAndRunAdorner

          public static MorphAdorner createAndRunAdorner(java.lang.String adornerName,
                                         boolean replaceAdorner,
                                         java.lang.String[] adornerArgs,
                                         java.lang.String adornerLogConfig,
                                         java.lang.String adornerLogDirectory,
                                         java.lang.String outputDirectory,
                                         java.lang.String[] filesToAdorn,
                                         boolean tokenizeOnly)

      Create and run a Morphological Adorner.
      Parameters:
        `adornerName` - Name for this adorner.
        `replaceAdorner` - Replace existing adorner.
        `adornerArgs` - Adorner arguments.
        `adornerLogConfig` - Adorner log file configuration.
        `adornerLogDirectory` - Adorner log directory.
        `outputDirectory` - Adorned files output directory.
        `filesToAdorn` - File names to adorn.
        `tokenizeOnly` - Only tokenize XML files.
      Returns:
        The adorner.

    - #### finalize

          public void finalize()
                        throws java.lang.Throwable

      Finalize.
      Overrides:
        `finalize` in class `java.lang.Object`
      Throws:
        `java.lang.Throwable`