edu.northwestern.at.morphadorner.corpuslinguistics.inputter

## Class URLTextInputter

- java.lang.Object
- - edu.northwestern.at.utils.IsCloseableObject
  - - edu.northwestern.at.morphadorner.corpuslinguistics.inputter.URLTextInputter

- All Implemented Interfaces:
    TextInputter
  Direct Known Subclasses:
    DefaultTextInputter, FirstTokenURLTextInputter

      public class URLTextInputter
      extends IsCloseableObject
      implements TextInputter

  Text inputter which reads text from a URL.

  Strips tags naively from files which appear to contain HTML text.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String` | `loadedText` The loaded text.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `URLTextInputter()` Create URL text inputter.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `enableGapFixer(boolean fixGaps)` Enable gap element fixer.
    `void` | `enableOrigFixer(boolean fixOrig)` Enable orig element fixer.
    `void` | `enableSplitWordsFixer(boolean fixSplitWords, java.util.List<PatternReplacer> patternReplacers)` Enable split words fixer.
    `int` | `getSegmentCount()` Returns number of text segments.
    `java.lang.String` | `getSegmentName(int segmentNumber)` Returns name of specified segment.
    `java.lang.String` | `getSegmentText(int segmentNumber)` Returns specified segment of loaded text.
    `java.lang.String` | `getSegmentText(java.lang.String segmentName)` Returns specified segment of loaded text.
    `void` | `loadText(java.lang.String str)` Reads text from a String.
    `void` | `loadText(java.lang.String str, java.lang.String xmlSchemaURI)` Reads text from a string using a specified XML schema.
    `void` | `loadText(java.net.URL url, java.lang.String encoding)` Loads text from a URL.
    `void` | `loadText(java.net.URL url, java.lang.String encoding, java.lang.String xmlSchemaURI)` Loads text from a URL.
    `void` | `setSegmentText(int segmentNumber, java.io.File segmentTextFile)` Updates specified segment of loaded text from file.
    `void` | `setSegmentText(int segmentNumber, java.lang.String segmentText)` Updates specified segment of loaded text.
    `void` | `setSegmentText(java.lang.String segmentName, java.io.File segmentTextFile)` Returns specified segment of loaded text.
    `void` | `setSegmentText(java.lang.String segmentName, java.lang.String segmentText)` Returns specified segment of loaded text.
    `boolean` | `usesSegmentFiles()` Does inputter use segment files?

    - ### Methods inherited from class edu.northwestern.at.utils.IsCloseableObject

      `close`

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

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

- - ### Field Detail

    - #### loadedText

          protected java.lang.String loadedText

      The loaded text.

  - ### Constructor Detail

    - #### URLTextInputter

          public URLTextInputter()

      Create URL text inputter.

  - ### Method Detail

    - #### loadText

          public void loadText(java.net.URL url,
                      java.lang.String encoding)
                        throws java.io.IOException

      Loads text from a URL.
      Specified by:
        `loadText` in interface `TextInputter`
      Parameters:
        `url` - URL from which to read text.
        `encoding` - Text encoding.
      Throws:
        `java.io.IOException` - If an output error occurs.

    - #### loadText

          public void loadText(java.net.URL url,
                      java.lang.String encoding,
                      java.lang.String xmlSchemaURI)
                        throws java.io.IOException

      Loads text from a URL.
      Specified by:
        `loadText` in interface `TextInputter`
      Parameters:
        `url` - URL from which to read text.
        `encoding` - Text encoding.
        `xmlSchemaURI` - XML schema (ignored).
      Throws:
        `java.io.IOException` - If an output error occurs.

    - #### loadText

          public void loadText(java.lang.String str)
                        throws java.lang.Exception

      Reads text from a String.
      Specified by:
        `loadText` in interface `TextInputter`
      Parameters:
        `str` - String from which to read text.
      Throws:
        `java.io.IOException` - If an error occurs.
        `java.lang.Exception`

    - #### loadText

          public void loadText(java.lang.String str,
                      java.lang.String xmlSchemaURI)
                        throws java.lang.Exception

      Reads text from a string using a specified XML schema.
      Specified by:
        `loadText` in interface `TextInputter`
      Parameters:
        `str` - String from which to read text.
        `xmlSchemaURI` - String URI specifying Xml schema.
      Throws:
        `java.lang.Exception` - If an error occurs.

        The schema and schema type should be ignored when the input is not an XML file.

    - #### getSegmentCount

          public int getSegmentCount()

      Returns number of text segments.
      Specified by:
        `getSegmentCount` in interface `TextInputter`
      Returns:
        Number of text segments.

    - #### getSegmentName

          public java.lang.String getSegmentName(int segmentNumber)

      Returns name of specified segment.
      Specified by:
        `getSegmentName` in interface `TextInputter`
      Parameters:
        `segmentNumber` - The segment number (starts at 0).
      Returns:
        The name for the specified segment number, or null if the segment number is invalid.

    - #### getSegmentText

          public java.lang.String getSegmentText(int segmentNumber)

      Returns specified segment of loaded text.
      Specified by:
        `getSegmentText` in interface `TextInputter`
      Parameters:
        `segmentNumber` - The segment number (starts at 0).
      Returns:
        The text for for the specified segment number, or null if the segment number is invalid. The returned text may be an empty string if the segment number is valid but the segment contains no text.

    - #### getSegmentText

          public java.lang.String getSegmentText(java.lang.String segmentName)

      Returns specified segment of loaded text.
      Specified by:
        `getSegmentText` in interface `TextInputter`
      Parameters:
        `segmentName` - The segment name.
      Returns:
        The text for for the specified segment name, or null if the segment name is invalid. The returned text may be an empty string if the segment name is valid but the segment contains no text.

    - #### setSegmentText

          public void setSegmentText(int segmentNumber,
                            java.lang.String segmentText)

      Updates specified segment of loaded text.
      Specified by:
        `setSegmentText` in interface `TextInputter`
      Parameters:
        `segmentNumber` - The segment number (starts at 0).
        `segmentText` - The updated segment text.

    - #### setSegmentText

          public void setSegmentText(java.lang.String segmentName,
                            java.lang.String segmentText)

      Returns specified segment of loaded text.
      Specified by:
        `setSegmentText` in interface `TextInputter`
      Parameters:
        `segmentName` - The segment name.
        `segmentText` - The updated segment text.

    - #### setSegmentText

          public void setSegmentText(int segmentNumber,
                            java.io.File segmentTextFile)

      Updates specified segment of loaded text from file.
      Specified by:
        `setSegmentText` in interface `TextInputter`
      Parameters:
        `segmentNumber` - The segment number (starts at 0).
        `segmentTextFile` - The file containing the updated segment text.

    - #### setSegmentText

          public void setSegmentText(java.lang.String segmentName,
                            java.io.File segmentTextFile)

      Returns specified segment of loaded text.
      Specified by:
        `setSegmentText` in interface `TextInputter`
      Parameters:
        `segmentName` - The segment name.
        `segmentTextFile` - The file containing the updated segment text.

    - #### enableGapFixer

          public void enableGapFixer(boolean fixGaps)

      Enable gap element fixer.
      Specified by:
        `enableGapFixer` in interface `TextInputter`
      Parameters:
        `fixGaps` - true to fix gap tags.

        No-op here.

    - #### enableOrigFixer

          public void enableOrigFixer(boolean fixOrig)

      Enable orig element fixer.
      Specified by:
        `enableOrigFixer` in interface `TextInputter`
      Parameters:
        `fixOrig` - true to fix orig tags.

        No-op here.

    - #### enableSplitWordsFixer

          public void enableSplitWordsFixer(boolean fixSplitWords,
                                   java.util.List<PatternReplacer> patternReplacers)

      Enable split words fixer.
      Specified by:
        `enableSplitWordsFixer` in interface `TextInputter`
      Parameters:
        `fixSplitWords` - true to fix selected split words.
        `patternReplacers` - Patterns for fixing split words.

        No-op here.

    - #### usesSegmentFiles

          public boolean usesSegmentFiles()

      Does inputter use segment files?
      Specified by:
        `usesSegmentFiles` in interface `TextInputter`
      Returns:
        true if inputter uses segment files.