Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.opencyc.templateparser
Class TemplateParser

    java.lang.Object
      |
      +--org.opencyc.templateparser.TemplateParser

public class TemplateParser
extends java.lang.Object

Parses chat text, matching the best of a set of templates and returning an event plus arguments.

Author:
  Stephen L. Reed

  Copyright 2001 Cycorp, Inc., license is open source GNU LGPL.

  the license

  www.opencyc.org

  OpenCyc at SourceForge

  THIS SOFTWARE AND KNOWLEDGE BASE CONTENT ARE PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENCYC ORGANIZATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE AND KNOWLEDGE BASE CONTENT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Field Summary
`static int` | `DEFAULT_VERBOSITY` The default verbosity of the solution output.
`protected java.util.ArrayList` | `relevantTemplates` the relevant templates
`protected java.util.ArrayList` | `templates` the templates
`protected int` | `verbosity` Sets verbosity of the constraint solver output.

Constructor Summary
`TemplateParser()` Constructs a new TemplateParser object.

Method Summary
`protected boolean` | `canParseChunkWithoutCapturing(java.util.ArrayList partialInputWords, java.util.ArrayList templateWords)` Returns true iff the given partial input words be parsed without capturing any variable text, by the given template words.
`protected java.lang.Object[]` | `getNextTemplateWords(CycList partialTemplateElements)` Returns an array of three objects given the partialTemplateElements.
`java.util.ArrayList` | `getTemplates()` Returns the templates.
`void` | `initialize()` Initializes this object.
`protected java.lang.Object[]` | `parse(java.util.ArrayList partialInputWords, CycList partialTemplateElements, ParseResults parseResults)` Parses the partial input words, placing the results into parseResults, and returning an array of two objects: the first is the new partialInputWords and the second is the new partialTemplateElements.
`ParseResults` | `parse(java.lang.String inputText)` Parses the given text string using the first matching template.
`protected java.lang.Object[]` | `parseChunkWithCapturing(java.util.ArrayList partialInputWords, java.util.ArrayList templateWords)` Parses the partial input words, capturing any words before matching the templateWords.
`protected java.lang.Object[]` | `parseIntoWords(java.lang.String inputText)` Parses the input words and punctuation from given input text.
`void` | `setRelevantTemplates(java.util.ArrayList relevantTemplates)` Sets the relevant templates.
`void` | `setVerbosity(int verbosity)` Sets verbosity of the output.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_VERBOSITY

    public static final int DEFAULT_VERBOSITY

  The default verbosity of the solution output. 0 --> quiet ... 9 -> maximum diagnostic input.

### verbosity

    protected int verbosity

  Sets verbosity of the constraint solver output. 0 --> quiet ... 9 -> maximum diagnostic input.

### templates

    protected java.util.ArrayList templates

  the templates

### relevantTemplates

    protected java.util.ArrayList relevantTemplates

  the relevant templates

Constructor Detail

### TemplateParser

    public TemplateParser()

  Constructs a new TemplateParser object.

Method Detail

### initialize

    public void initialize()

  Initializes this object.

### parse

    public ParseResults parse(java.lang.String inputText)

  Parses the given text string using the first matching template. If relevantTemplates is not null, then only the relevant templates are used, and reset to null when the parse is complete.
  Parameters:
    `inputText` - the text string to be parsed
  Returns:
    the ParseResults

### parse

    protected java.lang.Object[] parse(java.util.ArrayList partialInputWords,
                                       CycList partialTemplateElements,
                                       ParseResults parseResults)

  Parses the partial input words, placing the results into parseResults, and returning an array of two objects: the first is the new partialInputWords and the second is the new partialTemplateElements. Recurses to handle variables in the template.
  Parameters:
    `partialInputWords` - the partial input text string
    `partialTemplateElements` - the partial template expression
    `parseResults` - the parseResults object so far
  Returns:
    an array of two objects: the first is the new partialInputWords and the second is the new partialTemplateElements

### parseIntoWords

    protected java.lang.Object[] parseIntoWords(java.lang.String inputText)

  Parses the input words and punctuation from given input text. Returns an array of two objects; the first object is the list of input words and the second object is the terminal punctuation character, or the empty string if no terminal punctuation
  Parameters:
    `inputText` - the input text
  Returns:
    an array of two objects; the first object is the list of input words and the second object is the terminal punctuation character, or the empty string if no terminal punctuation

### getNextTemplateWords

    protected java.lang.Object[] getNextTemplateWords(CycList partialTemplateElements)

  Returns an array of three objects given the partialTemplateElements. The first object returned is the variable preceding the group of template words (or null if there is none), the second object returned is the group of template words (up to the end of the template elements or the next variable, and the third is the new partialTemplateElements.
  Parameters:
    `partialTemplateElements` - the partial template elements
  Returns:
    an array of three objects given the partialTemplateElements. The first object returned is the variable preceding the group of template words (or null if there is none), the second object returned is the group of template words (up to the end of the template elements or the next variable), and the third is the new partialTemplateElements

### parseChunkWithCapturing

    protected java.lang.Object[] parseChunkWithCapturing(java.util.ArrayList partialInputWords,
                                                         java.util.ArrayList templateWords)

  Parses the partial input words, capturing any words before matching the templateWords. Returns an array of three objects: the first is a Boolean which is true iff the partial input words match the given template words, the second is the list of words captured from the partial input words before matching the template words, the third object returned is the remaining partialInputWords after the matching is performed.
  Parameters:
    `partialInputWords` - the partial input text words
    `templateWords` - the template words (up to the end of the template, or to the next variable in the template)
  Returns:
    an array of three objects: the first is a Boolean which is true iff the partial input words match the given template words, the second is the list of words captured from the partial input words before matching the template words, the third object returned is the remaining partialInputWords after the matching is performed

### canParseChunkWithoutCapturing

    protected boolean canParseChunkWithoutCapturing(java.util.ArrayList partialInputWords,
                                                    java.util.ArrayList templateWords)

  Returns true iff the given partial input words be parsed without capturing any variable text, by the given template words.
  Parameters:
    `partialInputWords` - the partial input words
    `templateWords` - the template words (up to the end of the template elements or the next variable)
  Returns:
    true iff the given partial input words can be parsed, without capturing any variable text, by the given template words

### getTemplates

    public java.util.ArrayList getTemplates()

  Returns the templates.
  Returns:
    the templates

### setRelevantTemplates

    public void setRelevantTemplates(java.util.ArrayList relevantTemplates)

  Sets the relevant templates.
  Parameters:
    `relevantTemplates` - the relevant templates for constrained parsing

### setVerbosity

    public void setVerbosity(int verbosity)

  Sets verbosity of the output. 0 --> quiet ... 9 -> maximum diagnostic input.
  Parameters:
    `verbosity` - 0 --> quiet ... 9 -> maximum diagnostic input

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD