|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectinfo.ephyra.answerselection.filters.Filter
info.ephyra.answerselection.filters.AnswerPatternFilter
public class AnswerPatternFilter
The AnswerPatternFilter uses answer patterns to extract
factoid answers from text passages and to rank them. It is only applied if
the question could be interpreted, i.e. a QuestionInterpretation
is available.
In addition, this Filter provides methods to add, load, save
and assess the answer patterns.
This class extends the class Filter.
| Field Summary | |
|---|---|
private static java.util.ArrayList<AnswerPattern> |
aps
For each PROPERTY object the answer pattern used to extract it. |
private static java.util.ArrayList<java.lang.String> |
extr
PROPERTY objects extracted from a Result. |
static java.lang.String |
ID
Identifier for the pattern learning and matching approach. |
private static java.util.Hashtable<java.lang.String,java.lang.Integer> |
nOfPassages
For each PROPERTY the number of text passages used to assess the answer patterns. |
private static java.util.Hashtable<java.lang.String,java.util.HashSet<AnswerPattern>> |
props
For each PROPERTY the answer patterns that are used to extract it. |
private static java.util.Hashtable<java.lang.String,java.lang.String> |
reverseMap
Maps tags in PROPERTY objects back to the original strings. |
private static java.util.ArrayList<java.lang.String> |
sents
For each PROPERTY object the sentence it was extracted from. |
private static java.util.ArrayList<java.lang.String[]> |
types
For each PROPERTY object the NE types. |
| Constructor Summary | |
|---|---|
AnswerPatternFilter()
|
|
| Method Summary | |
|---|---|
static boolean |
addPattern(java.lang.String expr,
java.lang.String prop)
Adds an answer pattern for a specific PROPERTY. |
Result[] |
apply(Result[] results)
Applies the answer patterns to the answer strings of the Result objects and creates a new Result for
each extracted unique answer. |
static void |
assessPatterns(Result result,
java.lang.String regex)
Assesses the answer patterns by applying them to the answer string of the Result object and comparing the extracted answers to the
regular expression |
static void |
dropLowConfidence(float confidenceThresh)
Drops answer patterns that have a confidence of confidenceThresh or less. |
static void |
dropLowSupport(float supportThresh)
Drops answer patterns that have a support of supportThresh
or less. |
private static void |
extractPos(Result result)
Applies the answer patterns to the answer string of the Result object to extract PROPERTY objects. |
private static java.lang.String[] |
getNeTypes(java.lang.String pos,
AnswerPattern pattern)
Gets the NE types that a PROPERTY object has in common with the answer pattern used to extract it. |
static boolean |
loadPatterns(java.lang.String dir)
Loads the answer patterns from a directory of PROPERTY files. |
private static java.lang.String |
prepSentence(java.lang.String sentence,
java.lang.String to,
java.lang.String[] cos,
java.lang.String[][] nes)
Prepares a sentence for answer extraction. |
private static java.lang.String |
replaceContext(java.lang.String sentence,
java.lang.String[] cos,
java.lang.String[][] nes)
Replaces all CONTEXT objects in the sentence. |
private static java.lang.String |
replaceNes(java.lang.String sentence,
java.lang.String[][] nes)
Replaces all NEs in the sentence. |
private static java.lang.String |
replaceTags(java.lang.String po)
Replaces tags in an extracted PROPERTY object with the original strings stored in reverseMap. |
private static java.lang.String |
replaceTarget(java.lang.String sentence,
java.lang.String to,
java.lang.String[][] nes)
Replaces all TARGET objects in the sentence. |
static boolean |
savePatterns(java.lang.String dir)
Saves the answer patterns to resource files. |
| Methods inherited from class info.ephyra.answerselection.filters.Filter |
|---|
apply |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String ID
private static java.util.Hashtable<java.lang.String,java.util.HashSet<AnswerPattern>> props
private static java.util.Hashtable<java.lang.String,java.lang.Integer> nOfPassages
private static java.util.Hashtable<java.lang.String,java.lang.String> reverseMap
private static java.util.ArrayList<java.lang.String> extr
Result.
private static java.util.ArrayList<java.lang.String[]> types
private static java.util.ArrayList<java.lang.String> sents
private static java.util.ArrayList<AnswerPattern> aps
| Constructor Detail |
|---|
public AnswerPatternFilter()
| Method Detail |
|---|
private static java.lang.String replaceTarget(java.lang.String sentence,
java.lang.String to,
java.lang.String[][] nes)
reverseMap.
sentence - input sentenceto - the TARGET object of the questionnes - the NEs in the sentence
null, if the sentence
does not contain the TARGET
private static java.lang.String replaceContext(java.lang.String sentence,
java.lang.String[] cos,
java.lang.String[][] nes)
reverseMap.
sentence - input sentencecos - the CONTEXT objects of the questionnes - the NEs in the sentence
private static java.lang.String replaceNes(java.lang.String sentence,
java.lang.String[][] nes)
reverseMap.
sentence - input sentencenes - the NEs in the sentence
private static java.lang.String prepSentence(java.lang.String sentence,
java.lang.String to,
java.lang.String[] cos,
java.lang.String[][] nes)
sentence - input sentenceto - the TARGET object of the questioncos - the CONTEXT objects of the questionnes - the NEs in the sentence
null, if
there is no TARGET object in the input sentence
private static java.lang.String[] getNeTypes(java.lang.String pos,
AnswerPattern pattern)
pos - PROPERTY objectpattern - answer pattern used to extract it
null if the answer pattern does not
expect specific typesprivate static java.lang.String replaceTags(java.lang.String po)
reverseMap.
po - PROPERTY object
private static void extractPos(Result result)
Result object to extract PROPERTY objects.
result - a Result object
public static boolean addPattern(java.lang.String expr,
java.lang.String prop)
expr - pattern descriptorprop - PROPERTY that the pattern extracts
public static boolean loadPatterns(java.lang.String dir)
AnswerPattern.
dir - directory of the answer patterns
public static boolean savePatterns(java.lang.String dir)
dir - directory of the answer patterns
public static void assessPatterns(Result result,
java.lang.String regex)
Result object and comparing the extracted answers to the
regular expression
result - Result objectregex - regular expression that describes a correct answerpublic static void dropLowSupport(float supportThresh)
supportThresh
or less.
supportThresh - the support thresholdpublic static void dropLowConfidence(float confidenceThresh)
confidenceThresh or less.
confidenceThresh - the confidence thresholdpublic Result[] apply(Result[] results)
Result objects and creates a new Result for
each extracted unique answer.
apply in class Filterresults - array of Result objects
Result objects
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||