edu.northwestern.at.morphadorner.tools.xmltotab

## Class XMLToTab

- java.lang.Object
- - edu.northwestern.at.morphadorner.tools.xmltotab.XMLToTab

-     public class XMLToTab
      extends java.lang.Object

  Convert MorphAdorner XML output to tab-separated tabular form.

  Usage:

  java edu.northwestern.at.morphadorner.tools.xmltotab.XMLToTab input.xml output.tab
  input.xml -- input XML file.
  output.tab -- output tab-separated values file.

  The attribute values for each "<w>" and "<pc>" element in the input XML file are extracted and output to a tab-separated values text file. An output line contains the following information corresponding to a single word "<w>" or "<pc>" element.

  1. The work ID.
  2. The permanent word ID.
  3. The uncorrected original spelling.
  4. The uncorrected original spelling reversed.
  5. The standard spelling.
  6. The lemma.
  7. The part of speech.
  8. The XPath-like path to this word. The leading work ID and trailing word number are removed from the path.
  9. The end of sentence flag. 1 if this word ends a sentence, 0 otherwise.
  10. The previous word's original spelling.
  11. The next word's original spelling.
  12. The previous word's parts of speech.
  13. The next word's parts of speech.
  14. Up to 80 characters of text preceding the word in the text.
  15. Up to 80 characters of text following the word in the text.
  16. The word label. May be empty.
  17. The div type of the nearest ancestor div element. May be empty.
  18. The word ordinal.

  This tabular representation of an adorned XML text is useful for data checking purposes. The morphological attribute values for each word element appear as columns. The 80 characters (or so) of text on either side of the word allows you to focus on particular part of speech tags and pinpoint errors from the automatic adornment process. The tab separated values may also be used to construct spreadsheets or databases of the individual word information.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `XMLToTab(java.lang.String[] args)` Supervises conversion of XML word elements to tabular form.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `displayUsage()` Display brief program usage.
    `protected static java.lang.String` | `fixPath(java.lang.String path)` Trim work ID and word number from word path.
    `static java.lang.String[]` | `getKWIC(java.lang.String id, int KWICWidth, java.util.List<java.lang.String> idList, AdornedXMLReader xmlReader)` Generate a KWIC line for a spelling.
    `static void` | `main(java.lang.String[] args)` Main program.

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

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

- - ### Constructor Detail

    - #### XMLToTab

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

      Supervises conversion of XML word elements to tabular form.
      Parameters:
        `args` - Command line arguments.

  - ### Method Detail

    - #### main

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

      Main program.

    - #### displayUsage

          public static void displayUsage()

      Display brief program usage.

    - #### fixPath

          protected static java.lang.String fixPath(java.lang.String path)

      Trim work ID and word number from word path.
      Parameters:
        `path` - Full path containing work ID and word number.
      Returns:
        Path trimmed of leading work ID and trailing word number.

    - #### getKWIC

          public static java.lang.String[] getKWIC(java.lang.String id,
                                   int KWICWidth,
                                   java.util.List<java.lang.String> idList,
                                   AdornedXMLReader xmlReader)

      Generate a KWIC line for a spelling.
      Parameters:
        `id` - Word ID the word for which to generate a KWIC.
        `KWICWidth` - Maximum width (in characters) of KWIC text.
        `idList` - List of word IDs
        `xmlReader` - The XML Reader.
      Returns:
        The KWIC sections as a String array. [0] = left KWIC text [1] = word [2] = right KWIC text