edu.stanford.nlp.ie.pcfg
Class GLUtil

java.lang.Object
  |
  +--edu.stanford.nlp.ie.pcfg.GLUtil

public class GLUtil
extends Object

Grammar/Lexicon Utility. Provides basic utility operations for generating grammars and lexicons


Field Summary
static boolean fancy
          outdated
 
Constructor Summary
GLUtil()
           
 
Method Summary
static List GetListRules(List trees, boolean isLex)
          Gets a list grammar or list lexicon from a list of trees.
static List GetProbGrammar(List trees)
          Gets a probabilistic grammar from the list of trees.
static List GetUniformGrammar(Tree tree, List tagCombinations)
          Gets a uniform grammar for a given tree.
static List GetUniformLexicon(Tree tree, List tagCombinations)
          Gets a uniform lexicon for a given tree.
static List MixRules(HashMap rules1, List rules2, double p)
          Calculates the union of two sets of rules (and interpolates probabilities linearly).
static List MixRules(HashMap rules1, List rules2, double p, double scaleFactor)
          Calculates the union of two sets of rules (and interpolates probabilities linearly).
static List MixRules(List rules1, List rules2, double p)
          Calculates the union of two sets of rules (and interpolates probabilities linearly).
static List MixRules(List rules1, List rules2, double p, double scaleFactor)
          Calculates the union of two sets of rules (and interpolates probabilities linearly).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fancy

public static boolean fancy
outdated

Constructor Detail

GLUtil

public GLUtil()
Method Detail

GetUniformGrammar

public static List GetUniformGrammar(Tree tree,
                                     List tagCombinations)
Gets a uniform grammar for a given tree. A uniform grammar includes all the tagged grammar rules that *could have* generated the tree. The process of creating a uniform grammar includes: 1) get all of the untagged grammar rules that compose the tree 2) for each rule, calculate all of the possible "tag assignments". e.g., if tagCombinations == [{}, {purchaser}] then the untagged grammar rule S -> NP VP+said would yield {S[{}] -> NP[{}] VP+said[{}], S[{purchaser}] -> NP[{purchaser}] VP+said[{}], .... Each rule has a probability of 1 (see code for other implementations...). GetUniformGrammar supports a variety of heuristic filters that can be used to limit the grammar size (see code). e.g., any tags that appear on the RHS of a rule must also appear on the LHS; the current implementation of GetUniformGrammar filters out rules that do not obey this.


GetUniformLexicon

public static List GetUniformLexicon(Tree tree,
                                     List tagCombinations)
Gets a uniform lexicon for a given tree. Gets all of the tagged lexical rules that could be used to generate the given (untagged) tree. Two steps: 1) Get all of the (untagged) lexical rules that compose the tree. 2) for each rule, calculate all of the possible "tag assignments". e.g., if tagCombinations == [{}, {purchaser}] then the untagged lexical rule NNP -> Amazon would yield NNP[{}] -> Amazon, NNP[{purchaser}] -> Amazon. Each rule has a probability of 1.


GetProbGrammar

public static List GetProbGrammar(List trees)
                           throws IOException
Gets a probabilistic grammar from the list of trees. Calls ExtractPTBRules.main.

IOException

GetListRules

public static List GetListRules(List trees,
                                boolean isLex)
                         throws IOException
Gets a list grammar or list lexicon from a list of trees. The list grammar/lexicon contains one instance of each grammar/lexicon rule for each time it would be used to generate the list of trees. e.g., if two trees contain "S -> NP VP", the list grammar would contain two instances of this rule. Each rule has a probability of 1.

IOException

MixRules

public static List MixRules(HashMap rules1,
                            List rules2,
                            double p,
                            double scaleFactor)
Calculates the union of two sets of rules (and interpolates probabilities linearly). The algorithm has been optimized for rules1.size() > rules2.size(). MixRules sets each rule's probability as scaleFactor * (p * rule1.p + (1 - p) * rule2.p)


MixRules

public static List MixRules(HashMap rules1,
                            List rules2,
                            double p)
Calculates the union of two sets of rules (and interpolates probabilities linearly). The algorithm has been optimized for rules1.size() > rules2.size(). MixRules sets each rule's probability as (p * rule1.p + (1 - p) * rule2.p)


MixRules

public static List MixRules(List rules1,
                            List rules2,
                            double p,
                            double scaleFactor)
Calculates the union of two sets of rules (and interpolates probabilities linearly). The algorithm has been optimized for rules1.size() > rules2.size(). MixRules sets each rule's probability as scaleFactor * (p * rule1.p + (1 - p) * rule2.p)


MixRules

public static List MixRules(List rules1,
                            List rules2,
                            double p)
Calculates the union of two sets of rules (and interpolates probabilities linearly). The algorithm has been optimized for rules1.size() > rules2.size(). MixRules sets each rule's probability as (p * rule1.p + (1 - p) * rule2.p)



Stanford NLP Group