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

## ch.uzh.ifi.attempto.ape
Class APELocal

    java.lang.Object
      ch.uzh.ifi.attempto.ape.ACEParser
          ch.uzh.ifi.attempto.ape.APELocal

    public class APELocal

extends ACEParser

This class provides an interface to the SWI Prolog executable of the Attempto Parsing Engine (APE). Note that you need the file "ape.exe" (which can be compiled from the Attempto APE distribution) and that SWI Prolog needs to be installed. Furthermore, you have to make sure that the JPL libraries of SWI Prolog are in the java library path. This can be achieved by a Java VM argument which looks like this (for Mac OS X):

> `-Djava.library.path=/opt/local/lib/swipl-5.6.45/lib/i386-darwin8.10.1`

It is very likely that the path is different on your machine. Just look for the directory that contains the file or symbolic link libjpl.jnilib (under Mac OS X), libjpl.dll (under Windows), or libjpl.so (under Unix). If you get the error message

> `java.lang.UnsatisfiedLinkError: no jpl in java.library.path`

then this is a strong indication that the SWI Prolog JPL libraries are not found.

Author:
  Tobias Kuhn

Constructor Summary
`APELocal(java.lang.String prologCommand, java.lang.String apeExeFile)` Creates a new parser object.

Method Summary
`void` | `addLexicon(Lexicon lexicon)` Loads the lexicon by adding all lexicon entries of the lexicon.
`void` | `addLexiconEntry(LexiconEntry lexiconEntry)` Adds a new lexicon entry.
`void` | `discardLexicon()` Discards the dynamically added lexicon entries.
`static APELocal` | `getInstance()` Returns the singleton APELocal instance.
`ACEParserResult` | `getMultiOutput(java.lang.String text, Lexicon lexicon, OutputType... outputTypes)` Returns multiple outputs for the given ACE text using the given lexicon.
`java.lang.String` | `getSoloOutput(java.lang.String text, Lexicon lexicon, OutputType outputType)` Returns one single output for the given ACE text using the given lexicon.
`static void` | `init(java.lang.String prologCommand, java.lang.String apeExeFile)` Initializes the APELocal singleton instance.
`static boolean` | `isInitialized()` Checks whether the singleton instance has already been initialized.

Methods inherited from class ch.uzh.ifi.attempto.ape.ACEParser
`getMultiOutput, getSoloOutput, getURI, isClexEnabled, isGuessingEnabled, setClexEnabled, setGuessingEnabled, setURI`

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

Constructor Detail

### APELocal

    public APELocal(java.lang.String prologCommand,
                    java.lang.String apeExeFile)

  Creates a new parser object. You can create at most one such object per JVM. If you try to create more than one such object or if you called the init method before then a runtime exception is thrown.

  Parameters:
    `prologCommand` - The command to run the SWI Prolog interpreter. On Windows this is usually "plcon", on Linux "pl", and on Mac "swipl".
    `apeExeFile` - The path (with filename) of the file "ape.exe".

Method Detail

### getInstance

    public static APELocal getInstance()

  Returns the singleton APELocal instance. Null is returned if the APELocal instance has not yet been initialized by the constructor or the init method.

  Returns:
    The singleton APELocal instance.

### init

    public static void init(java.lang.String prologCommand,
                            java.lang.String apeExeFile)

  Initializes the APELocal singleton instance. This method can be called at most once. If you call it twice or if you called the constructor before then a runtime exception is thrown.

  Parameters:
    `prologCommand` - The command to run the SWI Prolog interpreter. On Windows this is usually "plcon", on Linux "pl", and on Mac "swipl".
    `apeExeFile` - The path (with filename) of the file "ape.exe".

### isInitialized

    public static boolean isInitialized()

  Checks whether the singleton instance has already been initialized.

  Returns:
    true if the singleton instance has been initialized.

### getSoloOutput

    public java.lang.String getSoloOutput(java.lang.String text,
                                          Lexicon lexicon,
                                          OutputType outputType)
                                   throws ACEParserException

  Description copied from class: `ACEParser`
  Returns one single output for the given ACE text using the given lexicon. See the enumeration OutputType for further information about the possible outputs. If parsing succeeds then a string containing the result of the parser is returned. In the case of failure, an ACEParserException is thrown containing the error messages.

  Specified by:
    `getSoloOutput` in class `ACEParser`
  Parameters:
    `text` - The ACE text to be parsed.
    `lexicon` - The lexicon to be loaded.
    `outputType` - The kind of output that should be returned.
  Returns:
    The result as a string.
  Throws:
    `ACEParserException` - Contains the error messages if an error occurred.
  See Also:
    `ACEParser.getMultiOutput(String, Lexicon, OutputType...)`

### getMultiOutput

    public ACEParserResult getMultiOutput(java.lang.String text,
                                          Lexicon lexicon,
                                          OutputType... outputTypes)

  Description copied from class: `ACEParser`
  Returns multiple outputs for the given ACE text using the given lexicon. See the enumeration OutputType for further information about the possible outputs. The result is returned as an ACEParserResult object.

  Specified by:
    `getMultiOutput` in class `ACEParser`
  Parameters:
    `text` - The ACE text to be parsed.
    `lexicon` - The lexicon to be loaded.
    `outputTypes` - The kind of outputs that should be returned.
  Returns:
    A ParserResult object containing the outputs.
  See Also:
    `ACEParser.getSoloOutput(String, Lexicon, OutputType)`

### addLexicon

    public void addLexicon(Lexicon lexicon)

  Loads the lexicon by adding all lexicon entries of the lexicon. Note that these lexicon entries are automatically discarded the first time you call getSoloOutput or getMultiOutput with a lexicon parameter that is not null.

  Parameters:
    `lexicon` - The lexicon to be loaded.
  See Also:
    `addLexiconEntry(ch.uzh.ifi.attempto.ape.LexiconEntry)`, `discardLexicon()`

### addLexiconEntry

    public void addLexiconEntry(LexiconEntry lexiconEntry)

  Adds a new lexicon entry. Note that this lexicon entry is automatically discarded the first time you call getSoloOutput or getMultiOutput with a lexicon parameter that is not null.

  Parameters:
    `lexiconEntry` - The lexicon entry to be added.
  See Also:
    `addLexicon(ch.uzh.ifi.attempto.ape.Lexicon)`, `discardLexicon()`

### discardLexicon

    public void discardLexicon()

  Discards the dynamically added lexicon entries. Note that the lexicon entries that are complied into the SWI Prolog executable are not affected by this operation.

  See Also:
    `addLexiconEntry(ch.uzh.ifi.attempto.ape.LexiconEntry)`, `addLexicon(ch.uzh.ifi.attempto.ape.Lexicon)`

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

Copyright 2008, Attempto Group, University of Zurich (see http://attempto.ifi.uzh.ch)