edu.northwestern.at.morphadorner.corpuslinguistics.sentencemelder

## Class SentenceMelder

- java.lang.Object
- - edu.northwestern.at.morphadorner.corpuslinguistics.sentencemelder.SentenceMelder

- Direct Known Subclasses:
    AdornedXMLReader.MySentenceMelder, XMLSentenceMelder

      public class SentenceMelder
      extends java.lang.Object

  Sentence melder

  Constructs a formatted sentence by melding a list of sentence tokens containing words and punctuation.

  Example: Printing reconstituted sentence text.

  Assume "sentences" is a java.util.List of sentences. Each entry in "sentences" is a sentence -- a list of words expressed as a java.util.list of word objects. The word objects may be simple strings or any object implementing a "toString()" method that yields the text associated with that word. In the following example, we use String as the type for the word objects.

  ``

        SentenceMelder melder   = new SentenceMelder();

        for ( int i = 0 ; i < sentences.size() ; i++ )
        {
            List sentence   = sentences.get( i );

            String sentenceText =
                melder.reconstituteSentence( sentences.get( i ) );

            System.out.println( sentenceText );
        }

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static java.lang.String` | `LDQUOTESTR` Left double curly quote.
    `protected static java.lang.String` | `LSQUOTESTR` Left single curly quote.
    `protected static java.lang.String` | `RDQUOTESTR` Right double curly quote.
    `protected static java.lang.String` | `RSQUOTESTR` Right single curly quote.
    `protected SentenceMelderState` | `state` Sentence melder state.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SentenceMelder()` Create sentence melder.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `endSentence()` Finish sentence.
    `SentenceMelderState` | `getState()` Get state.
    `void` | `outputBlank()` Add blank to sentence.
    `protected void` | `outputWord(java.lang.String word)` Add word to sentence.
    `void` | `processWord(java.lang.String word)` Process word.
    `java.lang.String` | `reconstituteSentence(java.util.List<?> sentence)` Reconstitute a list of words to a sentence.
    `void` | `reset()` Reset the melder.
    `void` | `setState(SentenceMelderState state)` Set state.
    `boolean` | `shouldOutputBlank(java.lang.String word, boolean isFirstWord)` Should blank be output.
    `void` | `startSentence()` Start sentence.

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

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

- - ### Field Detail

    - #### LSQUOTESTR

          protected static final java.lang.String LSQUOTESTR

      Left single curly quote.
      See Also:
        Constant Field Values

    - #### RSQUOTESTR

          protected static final java.lang.String RSQUOTESTR

      Right single curly quote.
      See Also:
        Constant Field Values

    - #### LDQUOTESTR

          protected static final java.lang.String LDQUOTESTR

      Left double curly quote.
      See Also:
        Constant Field Values

    - #### RDQUOTESTR

          protected static final java.lang.String RDQUOTESTR

      Right double curly quote.
      See Also:
        Constant Field Values

    - #### state

          protected SentenceMelderState state

      Sentence melder state.

  - ### Constructor Detail

    - #### SentenceMelder

          public SentenceMelder()

      Create sentence melder.

  - ### Method Detail

    - #### reconstituteSentence

          public java.lang.String reconstituteSentence(java.util.List<?> sentence)

      Reconstitute a list of words to a sentence.
      Parameters:
        `sentence` - List of words and punctuation in a sentence. Normally each word is a plain string, but the "toString()" operation is performed on each, so it may be any object type whose toString() yields a proper word (e.g., an AdornedWord).
      Returns:
        The reconstituted sentence as a string.

    - #### startSentence

          public void startSentence()

      Start sentence.

    - #### outputBlank

          public void outputBlank()

      Add blank to sentence.

    - #### outputWord

          protected void outputWord(java.lang.String word)

      Add word to sentence.
      Parameters:
        `word` - The word to add.

        In general this should not be called directly.

    - #### processWord

          public void processWord(java.lang.String word)

      Process word.
      Parameters:
        `word` - The word to add.

    - #### endSentence

          public java.lang.String endSentence()

      Finish sentence.
      Returns:
        Returned sentence.

    - #### shouldOutputBlank

          public boolean shouldOutputBlank(java.lang.String word,
                                  boolean isFirstWord)

      Should blank be output.
      Parameters:
        `word` - The word.
        `isFirstWord` - First word in sentence.
      Returns:
        True to output blank before word.

    - #### getState

          public SentenceMelderState getState()

      Get state.
      Returns:
        Sentence melder state.

    - #### setState

          public void setState(SentenceMelderState state)

      Set state.
      Parameters:
        `state` - The sentence melder state.

    - #### reset

          public void reset()

      Reset the melder.

      Clears the internal state which tracks quote mark pairing, word count, and the previous word encountered. Usually called between text divisions such as paragraphs.