analysis.parsing
Class EarleyParser

java.lang.Object
  extended by analysis.parsing.EarleyParser

public class EarleyParser
extends java.lang.Object

Parser using Earley's algorithm.

Author:
XZW

Constructor Summary
EarleyParser()
           
 
Method Summary
static java.lang.Integer[] getNextParses()
          Returns the next rightmost-derivation parses if exists.
static boolean parse(MyGrammar myGrammar, java.lang.String[] tokens)
          Returns true if the sentence belongs to the grammar
static java.lang.Integer[] parse2Parses(MyGrammar myGrammar, java.lang.String[] tokens)
          Returns the rightmost-derivation parses (production indices) if the sentence belongs to the grammar.
static Tuple parsing(MyGrammar myGrammar, java.lang.String[] tokens)
          Returns the ultimate tuple if the sentence belongs to the grammar
static java.lang.String[] partition(java.lang.String sentence)
          Partitions a sentence into tokens.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EarleyParser

public EarleyParser()
Method Detail

parsing

public static Tuple parsing(MyGrammar myGrammar,
                            java.lang.String[] tokens)
Returns the ultimate tuple if the sentence belongs to the grammar

Parameters:
myGrammar - the grammar for parsing
tokens - the tokens of the sentence
Returns:
the ultimate tuple if the sentence belong to the grammar

parse

public static boolean parse(MyGrammar myGrammar,
                            java.lang.String[] tokens)
Returns true if the sentence belongs to the grammar

Parameters:
myGrammar - the grammar for parsing
tokens - the tokens of the sentence
Returns:
true if the sentence belongs to the grammar

parse2Parses

public static java.lang.Integer[] parse2Parses(MyGrammar myGrammar,
                                               java.lang.String[] tokens)
Returns the rightmost-derivation parses (production indices) if the sentence belongs to the grammar.

Parameters:
myGrammar - the grammar for parsing
tokens - the tokens of the sentence
Returns:
the rightmost-derivation parses if the sentence belongs to the grammar

getNextParses

public static java.lang.Integer[] getNextParses()
Returns the next rightmost-derivation parses if exists. It should be recalled after the function parse2Parses

Returns:
the next rightmost-derivation parses if exists.

partition

public static java.lang.String[] partition(java.lang.String sentence)
Partitions a sentence into tokens. Tokens of a sentence are separated by blanks.

Parameters:
sentence - the sentence to partition
Returns:
the tokens of the sentence.