edu.northwestern.at.morphadorner.tools

## Class AdornedXMLReader

- java.lang.Object
- - edu.northwestern.at.morphadorner.tools.AdornedXMLReader

-     public class AdornedXMLReader
      extends java.lang.Object

  Reads adorned word information from MorphAdorner XML output.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `AdornedXMLReader.MySentenceMelder` Custom sentence melder.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ExtendedAdornedWordFilter` | `wordInfoFilter` Adorned word information filter.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AdornedXMLReader(java.lang.String xmlInputFileName)` Create adorned XML reader.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.List<java.lang.String>` | `findWordsByMatchingLeadingPath(java.lang.String pattern)` Find words whose paths start with a given string.
    `java.util.List<java.lang.String>` | `findWordsByMatchingPath(java.lang.String pattern)` Find words matching a specified path regular expression pattern.
    `java.lang.String` | `generateXML(java.lang.String startingWordID, java.lang.String endingWordID)` Generate XML for selected word IDs.
    `java.util.List<java.lang.String>` | `getAdornedWordIDs()` Return list of adorned word IDs.
    `int` | `getAdornedWordIndexByID(java.lang.String id)` Get index for a word ID.
    `ExtendedAdornedWord` | `getExtendedAdornedWord(int index)` Get adorned word information for a word index.
    `ExtendedAdornedWord` | `getExtendedAdornedWord(java.lang.String id)` Get adorned word information for a word ID.
    `java.util.List<java.lang.String>` | `getRelatedSplitWordIDs(java.lang.String wordID)` Get related adorned word IDs for a word ID of a split word.
    `java.util.List<ExtendedAdornedWord>` | `getRelatedSplitWords(ExtendedAdornedWord adornedWordInfo)` Get related adorned words for split words.
    `java.util.List<java.lang.String>` | `getSelectedWordIDs(java.lang.String startingWordID, java.lang.String endingWordID)` Get list of selected word IDs from specified ID range.
    `java.util.List<java.util.List<ExtendedAdornedWord>>` | `getSentences()` Get adorned words as a list of sentences.
    `java.util.List<java.lang.String>` | `getSiblingWordIDs(java.lang.String wordID)` Get sibling words.
    `protected void` | `outputTag(java.lang.String tag, boolean openingTag, AdornedXMLReader.MySentenceMelder melder, XMLTagClassifier tagClassifier)` Output an XML tag.
    `protected void` | `readXML(java.lang.String xmlInputFileName)` Reads adorned XML.
    `java.lang.String[]` | `splitPath(java.lang.String path)` Split word path into separate tags.
    `java.lang.String[]` | `splitPathFull(java.lang.String path)` Split word path into separate tags.
    `java.lang.String` | `trimTag(java.lang.String tag)` Trim tag number from XML tag.

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

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

- - ### Field Detail

    - #### wordInfoFilter

          protected ExtendedAdornedWordFilter wordInfoFilter

      Adorned word information filter.

  - ### Constructor Detail

    - #### AdornedXMLReader

          public AdornedXMLReader(java.lang.String xmlInputFileName)
                           throws org.xml.sax.SAXException,
                                  java.io.IOException

      Create adorned XML reader.
      Parameters:
        `xmlInputFileName` - Input XML file name.
      Throws:
        `org.xml.sax.SAXException`
        `java.io.IOException`

  - ### Method Detail

    - #### readXML

          protected void readXML(java.lang.String xmlInputFileName)
                          throws org.xml.sax.SAXException,
                                 java.io.IOException

      Reads adorned XML.
      Parameters:
        `xmlInputFileName` - XML input file name.
      Throws:
        `org.xml.sax.SAXException`
        `java.io.IOException`

    - #### getAdornedWordIDs

          public java.util.List<java.lang.String> getAdornedWordIDs()

      Return list of adorned word IDs.
      Returns:
        List of adorned word IDs (strings).

    - #### getSentences

          public java.util.List<java.util.List<ExtendedAdornedWord>> getSentences()

      Get adorned words as a list of sentences.
      Returns:
        List of sentences. Each sentence is a list of ExtendedAdornedWord entries. Sentences are returned in reading context order. Only one ExtendedAdornedWord entry is returned for split words.

        This method tries to return sentences in as close to their order of appearance in the text as possible. Sentences from intrusive jump tags will generally appear after the text section into which they intrude, and so may be dislodged an arbitrary distance from their actual position in the text.

    - #### getExtendedAdornedWord

          public ExtendedAdornedWord getExtendedAdornedWord(java.lang.String id)

      Get adorned word information for a word ID.
      Parameters:
        `id` - The String word ID.
      Returns:
        ExtendedAdornedWord for the specified ID. Returns null if ID not found.

    - #### getExtendedAdornedWord

          public ExtendedAdornedWord getExtendedAdornedWord(int index)

      Get adorned word information for a word index.
      Parameters:
        `index` - The word index.
      Returns:
        ExtendedAdornedWord for the specified word index. Returns null if index not found.

    - #### getRelatedSplitWordIDs

          public java.util.List<java.lang.String> getRelatedSplitWordIDs(java.lang.String wordID)

      Get related adorned word IDs for a word ID of a split word.
      Parameters:
        `wordID` - Word ID for which related IDs are wanted.
      Returns:
        List of related word IDs.

        Related word IDs are the word IDs for the other parts of a split word. The returned list includes the given wordID.

        For unsplit words, the single given wordID is returned in the list.

        Null is returned when the wordID does not exist.

    - #### getRelatedSplitWords

          public java.util.List<ExtendedAdornedWord> getRelatedSplitWords(ExtendedAdornedWord adornedWordInfo)

      Get related adorned words for split words.
      Parameters:
        `adornedWordInfo` - Adorned word for which related words are wanted.
      Returns:
        List of related adorned words.

        Related words are those corresponding to the parts of a split word. The returned list includes the given word.

        For unsplit words, the single given adorned word is returned in the list.

    - #### getAdornedWordIndexByID

          public int getAdornedWordIndexByID(java.lang.String id)

      Get index for a word ID.
      Parameters:
        `id` - The String word ID.
      Returns:
        Index of word in adorned words list. Returns -1 ID not found.

    - #### getSiblingWordIDs

          public java.util.List<java.lang.String> getSiblingWordIDs(java.lang.String wordID)

      Get sibling words.
      Parameters:
        `wordID` - The word ID of the word for which to find siblings.
      Returns:
        String list of sibling word IDs. Empty list if no siblings found.

        Sibling words have the same parent hard or jump tag.

    - #### findWordsByMatchingLeadingPath

          public java.util.List<java.lang.String> findWordsByMatchingLeadingPath(java.lang.String pattern)

      Find words whose paths start with a given string.
      Parameters:
        `pattern` - The pattern to match.
      Returns:
        String list of words matching the pattern. Empty if no words match.

    - #### findWordsByMatchingPath

          public java.util.List<java.lang.String> findWordsByMatchingPath(java.lang.String pattern)

      Find words matching a specified path regular expression pattern.
      Parameters:
        `pattern` - The regular expression pattern to match.
      Returns:
        String list of words matching the pattern. Empty if no words match.

    - #### trimTag

          public java.lang.String trimTag(java.lang.String tag)

      Trim tag number from XML tag.
      Parameters:
        `tag` - XML tag to trim.
      Returns:
        Trimmed tag.

    - #### splitPathFull

          public java.lang.String[] splitPathFull(java.lang.String path)

      Split word path into separate tags.
      Parameters:
        `path` - The word path.
      Returns:
        String array of split XML tags. The trailing "w[]" element is removed.

    - #### splitPath

          public java.lang.String[] splitPath(java.lang.String path)

      Split word path into separate tags.
      Parameters:
        `path` - The word path.
      Returns:
        String array of split XML tags. Both the leading document name tag and the trailing word (w[]) tag are removed.

    - #### getSelectedWordIDs

          public java.util.List<java.lang.String> getSelectedWordIDs(java.lang.String startingWordID,
                                                            java.lang.String endingWordID)

      Get list of selected word IDs from specified ID range.
      Parameters:
        `startingWordID` - Starting word ID.
        `endingWordID` - Ending word ID.
      Returns:
        String list of selected word IDs.

    - #### generateXML

          public java.lang.String generateXML(java.lang.String startingWordID,
                                     java.lang.String endingWordID)

      Generate XML for selected word IDs.
      Parameters:
        `startingWordID` - Starting word ID.
        `endingWordID` - Ending word ID.
      Returns:
        Reconstituted XML encompassing the selected word IDs. Empty string if one or both of the word IDs is invalid or out of order.

    - #### outputTag

          protected void outputTag(java.lang.String tag,
                       boolean openingTag,
                       AdornedXMLReader.MySentenceMelder melder,
                       XMLTagClassifier tagClassifier)

      Output an XML tag.
      Parameters:
        `tag` - The XML tag to output.
        `openingTag` - True to generate opening tag, false otherwise.
        `melder` - XML sentence melder.
        `tagClassifier` - XML tag classifier.