|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectinfo.ephyra.answerselection.AnswerPattern
public class AnswerPattern
An AnswerPattern is applied to a sentence to extract a
PROPERTY object of the type specified in the property field.
The sentence must contain a TARGET tag to indicate the object of which the
PROPERTY is wanted.
This class implements the interface Comparable. Note: it has
a natural ordering that is inconsistent with equals().
| Field Summary | |
|---|---|
private int |
correct
Counter for the number of correct applications of the pattern. |
private java.lang.String |
desc
The pattern descriptor from which the pattern is built. |
private int |
distID
ID of the group that covers the string between TARGET and PROPERTY. |
private static int |
MAX_DIST
Maximum distance between TARGET and PROPERTY in tokens. |
private static int |
MAX_PROP
Maximum length of a PROPERTY object in tokens. |
private java.util.regex.Pattern |
pattern
The Pattern that is applied to a sentence. |
private java.lang.String |
property
The type of PROPERTY that is extracted with this pattern. |
private int |
propertyID
ID of the group that represents the PROPERTY to be extracted. |
private int |
wrong
Counter for the number of wrong applications of the pattern. |
| Constructor Summary | |
|---|---|
AnswerPattern(java.lang.String expr,
java.lang.String prop)
Creates an AnswerPattern from a descriptor that is a
regular expression but additionally contains the following tags:
<TO> - exactly one TARGET tag
<CO> - an arbitrary number of CONTEXT tags
<PO(_NExyz)*> - exactly one PROPERTY tag, optionally combined
with NE types
<NExyz(_NExyz)*> - an arbitrary number of NE tags, which are
combinations of one or more NE types
|
|
AnswerPattern(java.lang.String expr,
java.lang.String prop,
int correct,
int wrong)
Creates an AnswerPattern from a descriptor by applying
the constructor AnswerPattern(String expr, String prop). |
|
| Method Summary | |
|---|---|
private java.lang.String |
addDistGroup(java.lang.String expr)
Adds a capturing group that covers the string between the TARGET and the PROPERTY and sets the distID field. |
java.lang.String[] |
apply(java.lang.String sentence)
Applies the pattern to a sentence of space-delimited tokens containing a TARGET tag and optionally a number of CONTEXT and NE tags. |
int |
compareTo(AnswerPattern ap)
Compares two AnswerPattern objects by comparing the number
of correct applications. |
boolean |
equals(java.lang.Object o)
Compares this object to another AnswerPattern. |
float |
getConfidence()
Calculates a confidence measure for the pattern by applying the formula confidence = correct / (correct + wrong). |
int |
getCorrect()
Returns the number of correct applications of the pattern. |
java.lang.String |
getDesc()
Returns the pattern descriptor. |
java.lang.String |
getProperty()
Returns the type of PROPERTY that is extracted with this pattern. |
java.lang.String[] |
getPropertyTypes()
Returns the NE types that are allowed for a PROPERTY object to match the pattern. |
int |
getWrong()
Returns the number of wrong applications of the pattern. |
int |
hashCode()
The hashcode of an AnswerPattern is the hashcode of its
descriptor. |
void |
incCorrect()
Increments the number of correct applications by 1. |
void |
incWrong()
Increments the number of wrong applications by 1. |
private java.lang.String |
optimizePattern(java.lang.String expr)
Optimizes the pattern to improve its runtime performance. |
private java.lang.String |
replaceContextTags(java.lang.String expr)
Replaces CONTEXT tags by regular expressions that match CONTEXT tags with tag IDs. |
private java.lang.String |
replaceNeTags(java.lang.String expr)
Replaces NE tags by regular expressions that match NE tags with at least one of the NE types. |
private java.lang.String |
replacePropertyTag(java.lang.String expr)
Sets the propertyID field and replaces the PROPERTY tag by a
capturing group. |
private java.lang.String |
replaceTargetTag(java.lang.String expr)
Replaces the TARGET tag by a regular expression that matches TARGET tags with tag IDs. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final int MAX_DIST
private static final int MAX_PROP
private java.lang.String desc
private java.util.regex.Pattern pattern
Pattern that is applied to a sentence.
private java.lang.String property
private int propertyID
private int distID
private int correct
private int wrong
| Constructor Detail |
|---|
public AnswerPattern(java.lang.String expr,
java.lang.String prop)
AnswerPattern from a descriptor that is a
regular expression but additionally contains the following tags:
expr - pattern descriptorprop - PROPERTY that the pattern extracts
public AnswerPattern(java.lang.String expr,
java.lang.String prop,
int correct,
int wrong)
Creates an AnswerPattern from a descriptor by applying
the constructor AnswerPattern(String expr, String prop).
In addition, it sets the counters for the number of correct/wrong applications of the pattern.
expr - pattern descriptorprop - PROPERTY that the pattern extractscorrect - number of correct applicationswrong - number of wrong applications| Method Detail |
|---|
private java.lang.String addDistGroup(java.lang.String expr)
distID field. Required to measure
the distance between TARGET and PROPERTY.
expr - pattern descriptor
private java.lang.String replaceTargetTag(java.lang.String expr)
expr - pattern descriptor
private java.lang.String replaceContextTags(java.lang.String expr)
expr - pattern descriptor
private java.lang.String replacePropertyTag(java.lang.String expr)
propertyID field and replaces the PROPERTY tag by a
capturing group.
expr - pattern descriptor
private java.lang.String replaceNeTags(java.lang.String expr)
expr - pattern descriptor
private java.lang.String optimizePattern(java.lang.String expr)
expr - pattern descriptor
public boolean equals(java.lang.Object o)
AnswerPattern. Two
AnswerPattern objects are equal, iff the pattern descriptors
are equal.
equals in class java.lang.Objecto - the reference object with which to compare
true, iff this object is the same as the
o argumentpublic int compareTo(AnswerPattern ap)
AnswerPattern objects by comparing the number
of correct applications.
compareTo in interface java.lang.Comparable<AnswerPattern>ap - the AnswerPattern to be compared
AnswerPattern is less than, equal to or greater than
the specified AnswerPatternpublic int hashCode()
AnswerPattern is the hashcode of its
descriptor.
hashCode in class java.lang.Objectpublic java.lang.String getDesc()
public java.lang.String getProperty()
public int getCorrect()
public int getWrong()
public float getConfidence()
confidence = correct / (correct + wrong).
public void incCorrect()
public void incWrong()
public java.lang.String[] getPropertyTypes()
null iff no specific types are expectedpublic java.lang.String[] apply(java.lang.String sentence)
sentence - a sentence
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||