|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.stanford.nlp.ie.pcfg.XRule
Grammar rules with probabilities.
Field Summary | |
XLabel |
lhs
the left-hand side of the rule |
double |
p
the XRule's probability |
ArrayList |
rhs
the right-hand side of the rule. |
Constructor Summary | |
XRule(String s)
creates a new XRule by parsing a string. |
|
XRule(XLabel lhs)
creates a new XRule with an empty RHS and p == 1 |
Method Summary | |
void |
Copy(XRule fromRule,
boolean includeHead,
boolean includeTags)
copies head and tag information from fromRule. |
static List |
GetSimilar(XRule rule,
List rules,
boolean includeHead,
boolean includeTags)
Gets all the rules in a list that are similar to a key rule. |
List |
GetTags()
gets a list of all tags found anywhere in the rule |
static List |
GetTags(List rules)
gets a list of all tags found anywhere in a list of XRules |
int |
hashCode()
compares this XRule to another object. |
static ArrayList |
ReadRules(String fn)
Reads XRules from a file |
boolean |
Similar(XRule rule2,
boolean includeHead,
boolean includeTags)
compares two rules. |
static boolean |
Similar(XRule rule1,
XRule rule2,
boolean includeHead,
boolean includeTags)
compares two rules. |
String |
toString()
produces full string representation of XRule. |
String |
toString(boolean isLex)
XRules have the following string format: "LHS -> RHS %% p". |
String |
toString(boolean includeHead,
boolean includeTags)
XRules have the following string format: "LHS -> RHS %% p". |
String |
toString(boolean includeHead,
boolean includeLHSTags,
boolean includeRHSTags)
XRules have the following string format: "LHS -> RHS %% p". |
static void |
WriteRules(List rules,
String fn,
boolean isLex)
Writes rules to a file. |
static void |
WriteRules(List rules,
String fn,
boolean includeHead,
boolean includeLHSTags,
boolean includeRHSTags)
Writes rules to a file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public XLabel lhs
public ArrayList rhs
public double p
Constructor Detail |
public XRule(XLabel lhs)
public XRule(String s)
Method Detail |
public String toString(boolean includeHead, boolean includeLHSTags, boolean includeRHSTags)
includeHead
- true if head information should be included in
the output string.includeLHSTags
- true if tag information should be included in the
LHS of the output stringpublic String toString(boolean includeHead, boolean includeTags)
includeHead
- true if head information should be included in
the output string.includeTags
- true if tag information should be included in
the output string.public String toString(boolean isLex)
isLex
- calls toString(true, true, !isLex)public String toString()
toString
in class Object
public int hashCode()
hashCode
in class Object
public void Copy(XRule fromRule, boolean includeHead, boolean includeTags)
fromRule
- the rule supplying the head, tag informationincludeHead
- copy head informationincludeTags
- copy tag informationpublic boolean Similar(XRule rule2, boolean includeHead, boolean includeTags)
includeHead
- if false, ignore head information when making
comparison.includeTags
- if false, ignore tag information when making
comparison.
public static boolean Similar(XRule rule1, XRule rule2, boolean includeHead, boolean includeTags)
includeHead
- if false, ignore head information when making
comparisonincludeTags
- if false, ignore tag information when making
comparisonpublic List GetTags()
public static List GetTags(List rules)
rules
- a list of XRulespublic static ArrayList ReadRules(String fn) throws IOException
IOException
public static void WriteRules(List rules, String fn, boolean includeHead, boolean includeLHSTags, boolean includeRHSTags) throws IOException
rules
- a list of XRulesfn
- filenameincludeHead
- write head informationincludeLHSTags
- write left-hand side tagsincludeRHSTags
- write right-hand side tags
IOException
public static void WriteRules(List rules, String fn, boolean isLex) throws IOException
rules
- a list of XRulesfn
- filenameisLex
- if writing a lexicon (as opposed to a grammar). See
README
IOException
public static List GetSimilar(XRule rule, List rules, boolean includeHead, boolean includeTags)
rule
- the keyrules
- a list of XRules.includeHead
- use head information when computing similarity.
see XRule.SimilarincludeTags
- use tag information when computing similarity.
see XRule.Similar
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |