csli.dialog.app.calo.parse
Class GeminiJasper

java.lang.Object
  extended by csli.dialog.app.calo.parse.GeminiJasper
All Implemented Interfaces:
Service, RobustParserService

public class GeminiJasper
extends Object
implements Service, RobustParserService

Provides a Java interface to Gemini through the SICStus Prolog Jasper API. The interface provides methods to parse sentences and Word Confusion Networks (WCN)). The primary methods are

Although most usages will be to parse WCNs, for backwards compatible methods are still available to parse individual sentences:

Author:
jdowding

Nested Class Summary
 class GeminiJasper.invokePrologThread
          The class invokePrologThread is the sister thread to the invokeProlog method.
 class GeminiJasper.npThread
           
 class GeminiJasper.parseThread
          parseThread is a Thread that supports sending a parse command to Gemini.
 class GeminiJasper.parseWcnThread
          parseWcnThread implements a Thread to ask Gemini to parse a Word Confusion Network.
 
Constructor Summary
GeminiJasper()
          Constructor initializes the SICStus Prolog instance, and restores Gemini.
GeminiJasper(String[] argv)
          Constructor initializes the SICStus Prolog instance, and restores Gemini.
 
Method Summary
 ArrayList<String> findNPs(String sN)
           
 JPanel getGui()
          Get a Swing JPanel which provides a GUI to this service.
static GeminiJasper getInstance()
          Get the single static instance.
 String getTitle()
          Get the name of this service as it should appear in the GUI.
 void invokeProlog(String goal)
          Each unique way to invoke Prolog to execute a query requires a class which extends Thread, and a method to invoke the thread.
 boolean isServiceAlive()
          Is the service happy and alive?
static void main(String[] args)
           
 ArrayList<LFTerm> parse(String utterance)
           
 ArrayList<LFTerm> parse(String utterance, boolean expandDelayList)
          parse() preparses a parseThread to ask Gemini to parse a single sentence.
 ArrayList<Phrase> parseWcn(File wcnFile)
          parseWcn(File wcnFile) prepares a parseWcnThread to ask Gemini to parse the Word Confusion Network contained in the file.
 ArrayList<Phrase> parseWcn(SausageUtterance wcn)
          parseWcn(SausageUtterance wcn) prepares a parseWcnThread to ask Gemini to parse the Word Confusion Network.
 ArrayList<Phrase> parseWcn(String wcnString)
           
 ArrayList<Phrase> parseWcnBestNonOverlappingPhrases(File wcnFile)
          parseWcnBestNonOverlappingPhrases() prepares a parseWcnThread to ask Gemini to parse a Word Confusion Network.
 ArrayList<Phrase> parseWcnBestNonOverlappingPhrases(SausageUtterance wcn)
          parseWcnBestNonOverlappingPhrases() prepares a parseWcnThread to ask Gemini to parse a Word Confusion Network.
 ArrayList<Phrase> parseWcnSortPhrases(File wcnFile, String sortName)
          parseWcnSortPhrases() parses a Word Confusion Network, and returns the set of Noun Phrase phrases with a given sort found by the parser.
 ArrayList<Phrase> parseWcnSortPhrases(SausageUtterance wcn, String sortName)
          parseWcnSortPhrases() parses a Word Confusion Network, and returns the set of Noun Phrase phrases with a given sort found by the parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeminiJasper

public GeminiJasper()
Constructor initializes the SICStus Prolog instance, and restores Gemini. Does not requre accept any command line arguments for SICStus Prolog.


GeminiJasper

public GeminiJasper(String[] argv)
Constructor initializes the SICStus Prolog instance, and restores Gemini.

Parameters:
argv - a string array containing command line arguments for SICStus Prolog.
Method Detail

main

public static void main(String[] args)

getInstance

public static GeminiJasper getInstance()
Get the single static instance. Safer to use this rather than the constructor, to avoid trying to start more than one SICStus instance


findNPs

public ArrayList<String> findNPs(String sN)
Specified by:
findNPs in interface RobustParserService

getGui

public JPanel getGui()
Description copied from interface: Service
Get a Swing JPanel which provides a GUI to this service.

Specified by:
getGui in interface Service

getTitle

public String getTitle()
Description copied from interface: Service
Get the name of this service as it should appear in the GUI.

Specified by:
getTitle in interface Service

invokeProlog

public void invokeProlog(String goal)
Description copied from interface: RobustParserService
Each unique way to invoke Prolog to execute a query requires a class which extends Thread, and a method to invoke the thread. The method invokeProlog, and the class invokePrologThread allows an arbitrary call to Prolog which returns no results.

Specified by:
invokeProlog in interface RobustParserService
Parameters:
goal - - a String containing the Prolog term to call. It must end with a ".".

isServiceAlive

public boolean isServiceAlive()
Description copied from interface: Service
Is the service happy and alive?

Specified by:
isServiceAlive in interface Service
Returns:

parse

public ArrayList<LFTerm> parse(String utterance)
Specified by:
parse in interface RobustParserService

parse

public ArrayList<LFTerm> parse(String utterance,
                               boolean expandDelayList)
Description copied from interface: RobustParserService
parse() preparses a parseThread to ask Gemini to parse a single sentence. This is generally dispreffered in favor of the parseWcn() methods.

Specified by:
parse in interface RobustParserService
Parameters:
utterance - A String to parse
expandDelayList - a boolean to control whether under-constrained sort equations get assigned arbitrary values or not. If TRUE, then all sort expressions in the logical form will be unified with some sortally consistent value. If FALSE, then the DelayList term will contain the set of under-constrained sort equations.
Returns:
an Array of LFTerm objects containing all the Logical Forms found by the parser.

parseWcn

public ArrayList<Phrase> parseWcn(File wcnFile)
Description copied from interface: RobustParserService
parseWcn(File wcnFile) prepares a parseWcnThread to ask Gemini to parse the Word Confusion Network contained in the file.

Specified by:
parseWcn in interface RobustParserService
Returns:
- an Array of Phrase objects representing all the top-level Phrase objects found by the parser.

parseWcn

public ArrayList<Phrase> parseWcn(String wcnString)
Specified by:
parseWcn in interface RobustParserService

parseWcn

public ArrayList<Phrase> parseWcn(SausageUtterance wcn)
Description copied from interface: RobustParserService
parseWcn(SausageUtterance wcn) prepares a parseWcnThread to ask Gemini to parse the Word Confusion Network.

Specified by:
parseWcn in interface RobustParserService
Parameters:
wcn - - A SausageUtterance object containing the word confusion network to parse.
Returns:
- an Array of Phrase objects representing all the top-level Phrase objects found by the parser.

parseWcnBestNonOverlappingPhrases

public ArrayList<Phrase> parseWcnBestNonOverlappingPhrases(File wcnFile)
Description copied from interface: RobustParserService
parseWcnBestNonOverlappingPhrases() prepares a parseWcnThread to ask Gemini to parse a Word Confusion Network. This method finds the 1-best set of non-overlapping phrases found by the parser that jointly span as much of the WCN as possible.

Specified by:
parseWcnBestNonOverlappingPhrases in interface RobustParserService
Returns:
an Array of Phrase objects found by the parser that do not overlap.

parseWcnBestNonOverlappingPhrases

public ArrayList<Phrase> parseWcnBestNonOverlappingPhrases(SausageUtterance wcn)
Description copied from interface: RobustParserService
parseWcnBestNonOverlappingPhrases() prepares a parseWcnThread to ask Gemini to parse a Word Confusion Network. This method finds the 1-best set of non-overlapping phrases found by the parser that jointly span as much of the WCN as possible.

Specified by:
parseWcnBestNonOverlappingPhrases in interface RobustParserService
Parameters:
wcn - -A SausageUtterance object containing the word confusion network to parse.

parseWcnSortPhrases

public ArrayList<Phrase> parseWcnSortPhrases(File wcnFile,
                                             String sortName)
Description copied from interface: RobustParserService
parseWcnSortPhrases() parses a Word Confusion Network, and returns the set of Noun Phrase phrases with a given sort found by the parser.

Specified by:
parseWcnSortPhrases in interface RobustParserService
sortName - - the sortName of the semantic sort of Noun Phrase to look for. This should match a sort name defined in the Gemini hierarchy, in calo/src/broadcoverage/sorts_hierarchy.pl.
Returns:
An Array containing the set of Phrase objects corresponding to the NPs of the requested sort.

parseWcnSortPhrases

public ArrayList<Phrase> parseWcnSortPhrases(SausageUtterance wcn,
                                             String sortName)
Description copied from interface: RobustParserService
parseWcnSortPhrases() parses a Word Confusion Network, and returns the set of Noun Phrase phrases with a given sort found by the parser.

Specified by:
parseWcnSortPhrases in interface RobustParserService
Parameters:
wcn - A SausageUtterance object containing the word confusion network to parse.
sortName - - the sortName of the semantic sort of Noun Phrase to look for. This should match a sort name defined in the Gemini hierarchy, in calo/src/broadcoverage/sorts_hierarchy.pl.
Returns:
An Array containing the set of Phrase objects corresponding to the NPs of the requested sort.