edu.northwestern.at.morphadorner.tools.adornedtosimpleteip5

## Class AdornedToSimpleTEIP5

- java.lang.Object
- - edu.northwestern.at.morphadorner.tools.adornedtosimpleteip5.AdornedToSimpleTEIP5

-     public class AdornedToSimpleTEIP5
      extends java.lang.Object

  Convert MorphAdorned file to simple TEI P5 format.

  AdornedToSimpleTEIP5 converts a base-level MorphAdorner file to a more TEI P5-like format.

  Usage:

  > `adornedtosimpleteip5 outputdirectory [usereg|usechoice] interpgrp.xml goodfiles.txt badfiles.txt adorned1.xml adorned2.xml ...`

  where

  - outputdirectory specifies the output directory for the simplified TEI XML P5 format files.
  - usereg specifies that the standardized spelling should be emitted as a reg= attribute, while usechoice specifies that the standardized spelling should be emitted using TEI <choice> structure.
  - interpgrp.xml specifies the file name for a section of TEI XML which defines an interpGrp element for the part of speech tags. This can be an empty file in which case the interpGrp is not added to each output TEI XML file.
  - goodfiles.txt specifies the name of a file to receive the names of TEI XML files successfully converted to simple TEI P5 format.
  - badfiles.txt specifies the name of a file to receive the names of TEI XML files which could not be successfully converted to simple TEI P5 format.
  - adorned1.xml adorned2.xml ... specifies the input MorphAdorned XML files from which to produce TEI XML P5 versions.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static java.lang.String` | `badWorksFileName` File name of file to hold names of works which fail conversion.
    `protected static java.util.Set<java.lang.String>` | `badWorksSet` File names of works containing errors.
    `protected static int` | `currentDocNumber` Current document.
    `protected static int` | `docsToProcess` Number of documents to process.
    `protected static boolean` | `forceAna` Force ana=#pos output for part of speech.
    `protected static int` | `gapCount` Gap count.
    `protected static java.lang.String` | `goodWorksFileName` File name of file to hold names of works for which conversion succeeds.
    `protected static java.util.Set<java.lang.String>` | `goodWorksSet` File names of works converted successfully.
    `protected static boolean` | `haveInterpGrp` True if interGrp text is not empty.
    `protected static int` | `INITPARAMS` # params before input file specs.
    `protected static java.lang.String` | `interpGrpXMLText` XML text of interGrp section defining part of speech tags.
    `protected static java.lang.String` | `lastID` Last word ID processed.
    `protected static java.lang.String` | `outputDirectory` Output directory.
    `protected static java.io.PrintStream` | `printStream` Wrapper for printStream to allow utf-8 output.
    `protected static int` | `sentenceCount` Sentence count.
    `protected static org.jdom2.Namespace` | `teiNamespace` TEI name space.
    `protected static boolean` | `useReg` Use reg= instead of .

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AdornedToSimpleTEIP5()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected static void` | `addWordID(org.jdom2.Element wordElement, java.util.Set<java.lang.String> wordIDs)` Save word ID in set.
    `protected static org.jdom2.Element` | `cleanWElement(org.jdom2.Element element)` Clean word element.
    `protected static org.jdom2.Element` | `createElement(java.lang.String name)` Create an element.
    `protected static java.lang.String` | `displayElement(org.jdom2.Element element)` Display element.
    `protected static org.jdom2.Element` | `generateChoice(org.jdom2.Element element, java.lang.String wordText, java.lang.String regText)` Generate choice element for word structure.
    `protected static void` | `handleGap(org.jdom2.Content content, boolean inSplit, java.util.List<org.jdom2.Element> splitWordElements)` Handle gap tag.
    `protected static void` | `handleSup(org.jdom2.Content content)` Handle sup tag.
    `protected static int` | `handleW(java.util.List<org.jdom2.Content> contents, int index)` Handle w tag.
    `protected static boolean` | `initialize(java.lang.String[] args)` Initialize.
    `static void` | `main(java.lang.String[] args)` Main program.
    `protected static int` | `processFiles(java.lang.String[] args)` Process files.
    `protected static void` | `processOneFile(java.lang.String xmlFileName)` Process one file.
    `protected static void` | `replaceSupWithHi(org.jdom2.Element element)` Replace sup with hi.
    `protected static void` | `terminate(int filesProcessed, long processingTime)` Terminate.

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

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

- - ### Field Detail

    - #### docsToProcess

          protected static int docsToProcess

      Number of documents to process.

    - #### currentDocNumber

          protected static int currentDocNumber

      Current document.

    - #### interpGrpXMLText

          protected static java.lang.String interpGrpXMLText

      XML text of interGrp section defining part of speech tags.

    - #### haveInterpGrp

          protected static boolean haveInterpGrp

      True if interGrp text is not empty.

    - #### forceAna

          protected static boolean forceAna

      Force ana=#pos output for part of speech.

    - #### useReg

          protected static boolean useReg

      Use reg= instead of .

    - #### outputDirectory

          protected static java.lang.String outputDirectory

      Output directory.

    - #### printStream

          protected static java.io.PrintStream printStream

      Wrapper for printStream to allow utf-8 output.

    - #### INITPARAMS

          protected static final int INITPARAMS

      # params before input file specs.
      See Also:
        Constant Field Values

    - #### lastID

          protected static java.lang.String lastID

      Last word ID processed.

    - #### gapCount

          protected static int gapCount

      Gap count.

    - #### sentenceCount

          protected static int sentenceCount

      Sentence count.

    - #### badWorksFileName

          protected static java.lang.String badWorksFileName

      File name of file to hold names of works which fail conversion.

    - #### badWorksSet

          protected static java.util.Set<java.lang.String> badWorksSet

      File names of works containing errors.

    - #### goodWorksFileName

          protected static java.lang.String goodWorksFileName

      File name of file to hold names of works for which conversion succeeds.

    - #### goodWorksSet

          protected static java.util.Set<java.lang.String> goodWorksSet

      File names of works converted successfully.

    - #### teiNamespace

          protected static org.jdom2.Namespace teiNamespace

      TEI name space.

  - ### Constructor Detail

    - #### AdornedToSimpleTEIP5

          public AdornedToSimpleTEIP5()

  - ### Method Detail

    - #### main

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

      Main program.
      Parameters:
        `args` - Program parameters.

    - #### initialize

          protected static boolean initialize(java.lang.String[] args)
                                       throws java.lang.Exception

      Initialize.
      Throws:
        `java.lang.Exception`

    - #### processOneFile

          protected static void processOneFile(java.lang.String xmlFileName)

      Process one file.
      Parameters:
        `xmlFileName` - Adorned XML file name to reformat for Xaira.

    - #### addWordID

          protected static void addWordID(org.jdom2.Element wordElement,
                       java.util.Set<java.lang.String> wordIDs)

      Save word ID in set.
      Parameters:
        `wordElement` - Word element.
        `wordIDs` - Set of word IDs.

    - #### handleW

          protected static int handleW(java.util.List<org.jdom2.Content> contents,
                    int index)

      Handle w tag.
      Parameters:
        `contents` - List of content nodes.
        `index` - Index of "w" node to process.
      Returns:
        Updated node index. May change if container "w" node added here.

    - #### cleanWElement

          protected static org.jdom2.Element cleanWElement(org.jdom2.Element element)

      Clean word element.
      Parameters:
        `element` - w element.

    - #### createElement

          protected static org.jdom2.Element createElement(java.lang.String name)

      Create an element.
      Parameters:
        `name` - Element name.

    - #### handleGap

          protected static void handleGap(org.jdom2.Content content,
                       boolean inSplit,
                       java.util.List<org.jdom2.Element> splitWordElements)

      Handle gap tag.
      Parameters:
        `content` - Node content.
        `inSplit` - Processing split word.
        `splitWordElements` - Split word elements.

    - #### handleSup

          protected static void handleSup(org.jdom2.Content content)

      Handle sup tag.
      Parameters:
        `content` - Node content.

    - #### replaceSupWithHi

          protected static void replaceSupWithHi(org.jdom2.Element element)

      Replace sup with hi.
      Parameters:
        `element` - sup element to convert and replace with hi.

    - #### displayElement

          protected static java.lang.String displayElement(org.jdom2.Element element)

      Display element.
      Parameters:
        `element` - Element to display.

    - #### generateChoice

          protected static org.jdom2.Element generateChoice(org.jdom2.Element element,
                                         java.lang.String wordText,
                                         java.lang.String regText)

      Generate choice element for word structure.
      Parameters:
        `element` - Parent element for choice structure.
        `wordText` - Original word text. May be null.
        `regText` - Standard spelling.
      Returns:
        element within .

        Emit a choice structure of the form:

              <w...>
                  <choice>
                      <orig>original spelling</orig>    or
                      <orig>
                          <seg ...>
                          <seg ...>
                          ...
                      </orig>
                      <reg>standard spelling</reg>
                  </choice>
              </w>

    - #### processFiles

          protected static int processFiles(java.lang.String[] args)

      Process files.

    - #### terminate

          protected static void terminate(int filesProcessed,
                       long processingTime)

      Terminate.
      Parameters:
        `filesProcessed` - Number of files processed.
        `processingTime` - Processing time in seconds.