edu.northwestern.at.morphadorner.tools.annolex

## Class CorrectedWordsFileReader

- java.lang.Object
- - edu.northwestern.at.morphadorner.tools.annolex.CorrectedWordsFileReader

-     public class CorrectedWordsFileReader
      extends java.lang.Object

  Reads word correction information file.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.Set<java.lang.String>` | `allowedWorkIDs` Allowed work IDs.
    `protected static int` | `CHECKBOX`
    `protected static int` | `CORLEM`
    `protected static int` | `CORPOS`
    `protected static int` | `CORSPELL`
    `protected static java.util.regex.Matcher` | `gapWordMatcher`
    `protected static java.util.regex.Pattern` | `gapWordPattern` Gap word matcher.
    `protected CorrectedWord` | `heldCorrectedWord` Held corrected word.
    `protected int` | `linesRead` Number of lines read.
    `protected static int` | `SPELL`
    `protected static int` | `STANSPELL`
    `static int` | `TABFIELDSCOUNT` Number of fields in tabular file.
    `protected CSVFileReader` | `tabFile` Tabular file holding corrected words definitions.
    `protected static int` | `UPDATEDID`
    `protected static int` | `WORDID`
    `protected static int` | `WORKID` Fields.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CorrectedWordsFileReader(java.lang.String tabInputFileName, java.util.Set<java.lang.String> allowedWorkIDs)` Create tab file reader.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `closeFile()` Close input file.
    `java.util.List<java.lang.String>` | `getCorrectedWordIDs()` Return list of all corrected word IDs.
    `java.util.List<CorrectedWord>` | `getCorrectedWords()` Return list of all corrected words.
    `java.util.Map<java.lang.String,CorrectedWord>` | `readAllCorrectedWords()` Read all corrected words to map.
    `java.util.Map<java.lang.String,CorrectedWord>` | `readCorrectedWords(int wordsToRead)` Read specified number of corrected words to map.
    `CorrectedWord` | `readNextCorrectedWord()` Read next corrected word.

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

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

- - ### Field Detail

    - #### TABFIELDSCOUNT

          public static final int TABFIELDSCOUNT

      Number of fields in tabular file.
      See Also:
        Constant Field Values

    - #### WORKID

          protected static final int WORKID

      Fields.
      See Also:
        Constant Field Values

    - #### WORDID

          protected static final int WORDID

      See Also:
        Constant Field Values

    - #### SPELL

          protected static final int SPELL

      See Also:
        Constant Field Values

    - #### CORSPELL

          protected static final int CORSPELL

      See Also:
        Constant Field Values

    - #### STANSPELL

          protected static final int STANSPELL

      See Also:
        Constant Field Values

    - #### CORLEM

          protected static final int CORLEM

      See Also:
        Constant Field Values

    - #### CORPOS

          protected static final int CORPOS

      See Also:
        Constant Field Values

    - #### CHECKBOX

          protected static final int CHECKBOX

      See Also:
        Constant Field Values

    - #### UPDATEDID

          protected static final int UPDATEDID

      See Also:
        Constant Field Values

    - #### gapWordPattern

          protected static java.util.regex.Pattern gapWordPattern

      Gap word matcher.

    - #### gapWordMatcher

          protected static final java.util.regex.Matcher gapWordMatcher

    - #### linesRead

          protected int linesRead

      Number of lines read.

    - #### tabFile

          protected CSVFileReader tabFile

      Tabular file holding corrected words definitions.

    - #### allowedWorkIDs

          protected java.util.Set<java.lang.String> allowedWorkIDs

      Allowed work IDs.

    - #### heldCorrectedWord

          protected CorrectedWord heldCorrectedWord

      Held corrected word.

  - ### Constructor Detail

    - #### CorrectedWordsFileReader

          public CorrectedWordsFileReader(java.lang.String tabInputFileName,
                                  java.util.Set<java.lang.String> allowedWorkIDs)
                                   throws java.io.IOException

      Create tab file reader.
      Parameters:
        `tabInputFileName` - Input tab file name.
        `allowedWorkIDs` - Allowed work IDs.

        If allowedWorkIDs is not null, only corrections for words whose workIDs match an entry in allowedWordIDs will be stored.

      Throws:
        `java.io.IOException`

  - ### Method Detail

    - #### readNextCorrectedWord

          public CorrectedWord readNextCorrectedWord()

      Read next corrected word.
      Returns:
        Corrected word. Null if no more words to read.

    - #### readCorrectedWords

          public java.util.Map<java.lang.String,CorrectedWord> readCorrectedWords(int wordsToRead)

      Read specified number of corrected words to map.
      Returns:
        Map of word ID to corrected word.

    - #### readAllCorrectedWords

          public java.util.Map<java.lang.String,CorrectedWord> readAllCorrectedWords()

      Read all corrected words to map.
      Returns:
        Map of word ID to corrected word.

    - #### getCorrectedWords

          public java.util.List<CorrectedWord> getCorrectedWords()

      Return list of all corrected words.
      Returns:
        List of all corrected words.

    - #### getCorrectedWordIDs

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

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

    - #### closeFile

          public void closeFile()

      Close input file.