edu.stanford.nlp.parser.lexparser
Class LexicalizedParserQuery

java.lang.Object
  extended by edu.stanford.nlp.parser.lexparser.LexicalizedParserQuery
All Implemented Interfaces:
ParserQuery

public class LexicalizedParserQuery
extends java.lang.Object
implements ParserQuery


Method Summary
 Tree getBestDependencyParse()
           
 Tree getBestDependencyParse(boolean debinarize)
           
 Tree getBestFactoredParse()
           
 Tree getBestParse()
          Return the best parse of the sentence most recently parsed.
 Tree getBestPCFGParse()
           
 Tree getBestPCFGParse(boolean stripSubcategories)
           
 java.util.List<ScoredObject<Tree>> getBestPCFGParses()
           
 KBestViterbiParser getDependencyParser()
           
 KBestViterbiParser getFactoredParser()
           
 java.util.List<ScoredObject<Tree>> getKBestPCFGParses(int k)
          Returns the trees (and scores) corresponding to the k-best derivations of the sentence.
 java.util.List<ScoredObject<Tree>> getKGoodFactoredParses(int k)
           
 KBestViterbiParser getPCFGParser()
           
 double getPCFGScore()
           
 TreePrint getTreePrint()
          Return a TreePrint for formatting parsed output trees.
 boolean hasFactoredParse()
           
 java.util.List<? extends HasWord> originalSentence()
           
 boolean parse(java.util.List<? extends HasWord> sentence)
          Parse a sentence represented as a List of tokens.
 boolean parseAndReport(java.util.List<? extends HasWord> sentence, java.io.PrintWriter pwErr)
          Implements the same parsing with fallback that parse() does, but also outputs status messages for failed parses to pwErr.
 boolean parseFallback()
          The model had to fall back to a simpler model on the previous parse
 boolean parseNoMemory()
          The model ran out of memory on the most recent parse
 boolean parseSkipped()
          The sentence was skipped, probably because it was too long or of length 0
 boolean parseSucceeded()
          Parsing succeeded without any horrible errors or fallback
 boolean parseUnparsable()
          The model could not parse the most recent sentence for some reason
 void restoreOriginalWords(Tree tree)
           
 boolean saidMemMessage()
           
 void setConstraints(java.util.List<ParserConstraint> constraints)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parseSucceeded

public boolean parseSucceeded()
Description copied from interface: ParserQuery
Parsing succeeded without any horrible errors or fallback

Specified by:
parseSucceeded in interface ParserQuery

parseSkipped

public boolean parseSkipped()
Description copied from interface: ParserQuery
The sentence was skipped, probably because it was too long or of length 0

Specified by:
parseSkipped in interface ParserQuery

parseFallback

public boolean parseFallback()
Description copied from interface: ParserQuery
The model had to fall back to a simpler model on the previous parse

Specified by:
parseFallback in interface ParserQuery

parseNoMemory

public boolean parseNoMemory()
Description copied from interface: ParserQuery
The model ran out of memory on the most recent parse

Specified by:
parseNoMemory in interface ParserQuery

parseUnparsable

public boolean parseUnparsable()
Description copied from interface: ParserQuery
The model could not parse the most recent sentence for some reason

Specified by:
parseUnparsable in interface ParserQuery

originalSentence

public java.util.List<? extends HasWord> originalSentence()
Specified by:
originalSentence in interface ParserQuery

saidMemMessage

public boolean saidMemMessage()
Specified by:
saidMemMessage in interface ParserQuery

setConstraints

public void setConstraints(java.util.List<ParserConstraint> constraints)
Specified by:
setConstraints in interface ParserQuery

restoreOriginalWords

public void restoreOriginalWords(Tree tree)
Specified by:
restoreOriginalWords in interface ParserQuery

getBestParse

public Tree getBestParse()
Return the best parse of the sentence most recently parsed. This will be from the factored parser, if it was used and it succeeded else from the PCFG if it was used and succeed, else from the dependency parser.

Specified by:
getBestParse in interface ParserQuery
Returns:
The best tree
Throws:
NoSuchParseException - If no previously successfully parsed sentence

getBestPCFGParses

public java.util.List<ScoredObject<Tree>> getBestPCFGParses()
Specified by:
getBestPCFGParses in interface ParserQuery

hasFactoredParse

public boolean hasFactoredParse()
Specified by:
hasFactoredParse in interface ParserQuery

getBestFactoredParse

public Tree getBestFactoredParse()
Specified by:
getBestFactoredParse in interface ParserQuery

getKGoodFactoredParses

public java.util.List<ScoredObject<Tree>> getKGoodFactoredParses(int k)
Specified by:
getKGoodFactoredParses in interface ParserQuery

getKBestPCFGParses

public java.util.List<ScoredObject<Tree>> getKBestPCFGParses(int k)
Returns the trees (and scores) corresponding to the k-best derivations of the sentence. This cannot be a Counter because frequently there will be multiple derivations which lead to the same parse tree.

Specified by:
getKBestPCFGParses in interface ParserQuery
Parameters:
k - The number of best parses to return
Returns:
The list of trees with their scores (log prob).

getBestPCFGParse

public Tree getBestPCFGParse()
Specified by:
getBestPCFGParse in interface ParserQuery

getBestPCFGParse

public Tree getBestPCFGParse(boolean stripSubcategories)

getPCFGScore

public double getPCFGScore()
Specified by:
getPCFGScore in interface ParserQuery

getBestDependencyParse

public Tree getBestDependencyParse()

getBestDependencyParse

public Tree getBestDependencyParse(boolean debinarize)
Specified by:
getBestDependencyParse in interface ParserQuery

parse

public boolean parse(java.util.List<? extends HasWord> sentence)
Parse a sentence represented as a List of tokens. The text must already have been tokenized and normalized into tokens that are appropriate to the treebank which was used to train the parser. The tokens can be of multiple types, and the list items need not be homogeneous as to type (in particular, only some words might be given tags):

Specified by:
parse in interface ParserQuery
Parameters:
sentence - The sentence to parse
Returns:
true Iff the sentence was accepted by the grammar. If the main grammar fails, but the PCFG succeeds, then this still returns true, but parseFallback() will also return true. getBestParse() will have a valid result iff this returns true.

parseAndReport

public boolean parseAndReport(java.util.List<? extends HasWord> sentence,
                              java.io.PrintWriter pwErr)
Implements the same parsing with fallback that parse() does, but also outputs status messages for failed parses to pwErr.

Specified by:
parseAndReport in interface ParserQuery

getTreePrint

public TreePrint getTreePrint()
Return a TreePrint for formatting parsed output trees.

Returns:
A TreePrint for formatting parsed output trees.

getPCFGParser

public KBestViterbiParser getPCFGParser()
Specified by:
getPCFGParser in interface ParserQuery

getDependencyParser

public KBestViterbiParser getDependencyParser()
Specified by:
getDependencyParser in interface ParserQuery

getFactoredParser

public KBestViterbiParser getFactoredParser()
Specified by:
getFactoredParser in interface ParserQuery


Stanford NLP Group