edu.stanford.nlp.parser
Interface KBestViterbiParser

All Superinterfaces:
Parser, ViterbiParser
All Known Implementing Classes:
BiLexPCFGParser, BiLexPCFGParser.N5BiLexPCFGParser, ExhaustiveDependencyParser, ExhaustivePCFGParser, FastFactoredParser, IterativeCKYPCFGParser

public interface KBestViterbiParser
extends ViterbiParser

An interface that supports finding k best and/or k good parses and parse sampling. These operations are specified by separate methods, but it is expected that many parsers will return an UnsupportedOperationException for some of these methods. This has some other methods that essentially provide a rich parser interface which is used by certain parsers in lexparser, including other convenience methods like hasParse() and getBestScore().

Author:
Christopher Manning

Method Summary
 List<ScoredObject<Tree>> getBestParses()
          Get a complete set of the maximally scoring parses for a sentence, rather than one chosen at random.
 double getBestScore()
          Gets the score (typically a log probability) of the best parse of a sentence.
 List<ScoredObject<Tree>> getKBestParses(int k)
          Get the exact k best parses for the sentence.
 List<ScoredObject<Tree>> getKGoodParses(int k)
          Get k good parses for the sentence.
 List<ScoredObject<Tree>> getKSampledParses(int k)
          Get k parse samples for the sentence.
 boolean hasParse()
          Does the sentence in the last call to parse() have a parse? In theory this method shouldn't be here, but it seemed a convenient place to put it for our more general parser interface.
 
Methods inherited from interface edu.stanford.nlp.parser.ViterbiParser
getBestParse
 
Methods inherited from interface edu.stanford.nlp.parser.Parser
parse, parse
 

Method Detail

getKBestParses

List<ScoredObject<Tree>> getKBestParses(int k)
Get the exact k best parses for the sentence.

Parameters:
k - The number of best parses to return
Returns:
The exact k best parses for the sentence, with each accompanied by its score (typically a negative log probability).

getBestParses

List<ScoredObject<Tree>> getBestParses()
Get a complete set of the maximally scoring parses for a sentence, rather than one chosen at random. This set may be of size 1 or larger.

Returns:
All the equal best parses for a sentence, with each accompanied by its score

getKGoodParses

List<ScoredObject<Tree>> getKGoodParses(int k)
Get k good parses for the sentence. It is expected that the parses returned approximate the k best parses, but without any guarantee that the exact list of k best parses has been produced. If a class really provides k best parses functionality, it is reasonable to also return this output as the k good parses.

Parameters:
k - The number of good parses to return
Returns:
A list of k good parses for the sentence, with each accompanied by its score

getKSampledParses

List<ScoredObject<Tree>> getKSampledParses(int k)
Get k parse samples for the sentence. It is expected that the parses are sampled based on their relative probability.

Parameters:
k - The number of sampled parses to return
Returns:
A list of k parse samples for the sentence, with each accompanied by its score

hasParse

boolean hasParse()
Does the sentence in the last call to parse() have a parse? In theory this method shouldn't be here, but it seemed a convenient place to put it for our more general parser interface.

Returns:
Whether the last sentence parsed had a parse

getBestScore

double getBestScore()
Gets the score (typically a log probability) of the best parse of a sentence.

Returns:
The score for the last sentence parsed.


Stanford NLP Group