edu.northwestern.at.morphadorner.tools.fixquotes

## Class FixQuotes

- java.lang.Object
- - edu.northwestern.at.morphadorner.tools.fixquotes.FixQuotes

-     public class FixQuotes
      extends java.lang.Object

  Fix quotes in ascii text files.

  Usage:

  >       java edu.northwestern.at.morphadorner.tools.fixquotes.FixQuotes input.txt output.txt

  input.txt -- input text file.
  output.txt -- output text file with quotes fixed.

  Based in part on the Perl and PHP "SmartyPants" programs by John Gruber, Brad Choate, and Michel Fortin.

  Since the "quotification" relies on heuristics, not all quotes will be converted correctly.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static java.lang.String` | `apos` Apostrophereplacement text.
    `protected static java.lang.String` | `dq` Temporary double quote marker.
    `protected static java.lang.String` | `ldquo` Left double quote replacement text.
    `protected static java.lang.String` | `lsquo` Left single quote replacement text.
    `protected static java.lang.String` | `rdquo` Right double quote replacement text.
    `protected static java.lang.String` | `rsquo` Right single quote replacement text.
    `protected static java.lang.String` | `sq` Temporary single quote marker.

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `FixQuotes()` Allow overrides but not instantiation.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.util.regex.Pattern` | `buildContractionsPattern(TaggedStrings contractions)` Build contractions pattern.
    `static TaggedStrings` | `loadContractions(java.lang.String contractionsURL)` Load list of non-breakable words and contractions.
    `static void` | `main(java.lang.String[] args)` Main program.
    `static java.lang.String` | `repairQuotes(java.lang.String s, java.util.regex.Matcher contractionsMatcher, TaggedStrings contractions)` Fix quotes and apostrophes in text.

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

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

- - ### Field Detail

    - #### lsquo

          protected static final java.lang.String lsquo

      Left single quote replacement text.
      See Also:
        Constant Field Values

    - #### ldquo

          protected static final java.lang.String ldquo

      Left double quote replacement text.
      See Also:
        Constant Field Values

    - #### rsquo

          protected static final java.lang.String rsquo

      Right single quote replacement text.
      See Also:
        Constant Field Values

    - #### rdquo

          protected static final java.lang.String rdquo

      Right double quote replacement text.
      See Also:
        Constant Field Values

    - #### apos

          protected static final java.lang.String apos

      Apostrophereplacement text.
      See Also:
        Constant Field Values

    - #### sq

          protected static final java.lang.String sq

      Temporary single quote marker.
      See Also:
        Constant Field Values

    - #### dq

          protected static final java.lang.String dq

      Temporary double quote marker.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### FixQuotes

          protected FixQuotes()

      Allow overrides but not instantiation.

  - ### Method Detail

    - #### main

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

      Main program.

    - #### repairQuotes

          public static java.lang.String repairQuotes(java.lang.String s,
                                      java.util.regex.Matcher contractionsMatcher,
                                      TaggedStrings contractions)

      Fix quotes and apostrophes in text.
      Parameters:
        `s` - The text to fix.
        `contractionsMatcher` - Matcher for known contractions.
      Returns:
        The fixed text.

        The following operations are performed on the input text to generate the fixed output text.

        - Single (ordinary) quotes used as apostrophes are converted to an apostrophe entry string (').
        - Single quotes used as left single quotes are converted to a left single quote entity string (‘).
        - Single quotes used as right single quotes are converted to a right single quote entity string (’).
        - Double quotes used as left double quotes are converted to a left double quote entity string (“).
        - Double quotes used as left quotes re converted to a left single quote entity string (”).

    - #### loadContractions

          public static TaggedStrings loadContractions(java.lang.String contractionsURL)

      Load list of non-breakable words and contractions.

    - #### buildContractionsPattern

          public static java.util.regex.Pattern buildContractionsPattern(TaggedStrings contractions)

      Build contractions pattern.
      Parameters:
        `contractions` - Contractions as a tagged strings list.
      Returns:
        Regular expression for matching contractions.