enumeration.conversion
Class Converter

java.lang.Object
  extended by enumeration.conversion.Converter

public class Converter
extends java.lang.Object

Conversion between concise tree and parse tree or sentence.

Author:
xzw

Constructor Summary
Converter()
          Creates an instance of converter
 
Method Summary
static java.lang.String composeTree(java.lang.String head, java.lang.String[] subtree)
          Composes the concise tree "head{subtree[0],...,subtree[subtree.length-1]}"
static java.lang.String conciseTree(int n, int i, int j)
          Constructs the concise tree "(n,i,j)"
static java.lang.String[] decomposeTree(java.lang.String tree, int[] intHead)
          Decomposes a given concise tree into intHead and tail
static int[] decomposeTreeHead(java.lang.String tree, int[] intHead)
          Decomposes the head of a given concise tree into intHead
static java.lang.String fromParseTree(MyGrammar grammar, java.lang.String ptree)
          Converts a parse tree to a concise tree
static java.lang.String fromSentence(MyGrammar grammar, java.lang.String sentence)
          Converts a sentence to a concise tree
static MySentence toMySentence(MyGrammar grammar, java.lang.String tree)
          Converts a concise tree to a sentence
static java.lang.String toParseTree(MyGrammar grammar, java.lang.String tree)
          Converts a concise tree to a parse tree
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Converter

public Converter()
Creates an instance of converter

Method Detail

conciseTree

public static java.lang.String conciseTree(int n,
                                           int i,
                                           int j)
Constructs the concise tree "(n,i,j)"

Parameters:
n - the hierarchy index
i - the variable index
j - the production sequence number whose RHS is i.
Returns:
the concise tree "(n,i,j)"

composeTree

public static java.lang.String composeTree(java.lang.String head,
                                           java.lang.String[] subtree)
Composes the concise tree "head{subtree[0],...,subtree[subtree.length-1]}"

Parameters:
head - the head part of the concise tree
subtree - the tail subtrees of the concise tree
Returns:
the concise tree "head{subtree[0],...,subtree[subtree.length-1]}"

decomposeTree

public static java.lang.String[] decomposeTree(java.lang.String tree,
                                               int[] intHead)
Decomposes a given concise tree into intHead and tail

Parameters:
tree - the concise tree to decompose
intHead - the head integer values
Returns:
the tail subtrees

decomposeTreeHead

public static int[] decomposeTreeHead(java.lang.String tree,
                                      int[] intHead)
Decomposes the head of a given concise tree into intHead

Parameters:
tree - the concise tree to decompose
intHead - the head integer values

toParseTree

public static java.lang.String toParseTree(MyGrammar grammar,
                                           java.lang.String tree)
Converts a concise tree to a parse tree

Parameters:
grammar - the grammar for enumeration
tree - the given concise tree
Returns:
the parse tree

toMySentence

public static MySentence toMySentence(MyGrammar grammar,
                                      java.lang.String tree)
Converts a concise tree to a sentence

Parameters:
grammar - the grammar for enumeration
tree - the given concise tree
Returns:
the sentence

fromSentence

public static java.lang.String fromSentence(MyGrammar grammar,
                                            java.lang.String sentence)
Converts a sentence to a concise tree

Parameters:
grammar - the grammar for enumeration
sentence - the given sentence
Returns:
the concise tree

fromParseTree

public static java.lang.String fromParseTree(MyGrammar grammar,
                                             java.lang.String ptree)
Converts a parse tree to a concise tree

Parameters:
grammar - the grammar for enumeration
ptree - the given parse tree
Returns:
the concise tree