info.ephyra.patternlearning
Class PatternExtractor

java.lang.Object
  extended by info.ephyra.patternlearning.PatternExtractor

public class PatternExtractor
extends java.lang.Object

Extracts answer patterns from text passages and adds them to the AnswerPatternFilter.

Version:
2006-04-04
Author:
Nico Schlaefer

Field Summary
private static int MAX_TAGS
          Maximum number of NE and CONTEXT tags in a pattern (for time performance).
 
Constructor Summary
PatternExtractor()
           
 
Method Summary
static void extract(Result result, java.lang.String as)
          Extracts answer patterns from the answer string of a Result object and adds them to the AnswerPatternFilter.
private static java.lang.String[] extractPatterns(java.lang.String sentence)
          Extract basic answer patterns from the sentence.
private static java.lang.String[] generalizePatterns(java.lang.String[] patterns, java.lang.String prop)
          Generates more generic patterns from the initial patterns.
private static java.lang.String prepSentence(java.lang.String sentence, java.lang.String to, java.lang.String[] cos, java.lang.String po, java.lang.String[][] nes)
          Prepares a sentence for pattern 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 replaceProperty(java.lang.String sentence, java.lang.String as, java.lang.String[][] nes)
          Replaces all PROPERTY objects in the sentence.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_TAGS

private static final int MAX_TAGS
Maximum number of NE and CONTEXT tags in a pattern (for time performance).

See Also:
Constant Field Values
Constructor Detail

PatternExtractor

public PatternExtractor()
Method Detail

replaceTarget

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.

Parameters:
sentence - input sentence
to - the TARGET object of the question
nes - the NEs in the sentence
Returns:
sentence with TARGET tags or null, if the sentence does not contain the TARGET

replaceProperty

private static java.lang.String replaceProperty(java.lang.String sentence,
                                                java.lang.String as,
                                                java.lang.String[][] nes)
Replaces all PROPERTY objects in the sentence.

Parameters:
sentence - input sentence
as - the answer to the question
nes - the NEs in the sentence
Returns:
sentence with PROPERTY tags or null, if the sentence does not contain the answer

replaceContext

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.

Parameters:
sentence - input sentence
cos - the CONTEXT objects of the question
nes - the NEs in the sentence
Returns:
sentence with CONTEXT tags

replaceNes

private static java.lang.String replaceNes(java.lang.String sentence,
                                           java.lang.String[][] nes)
Replaces all NEs in the sentence.

Parameters:
sentence - input sentence
nes - the NEs in the sentence
Returns:
sentence with NE tags

prepSentence

private static java.lang.String prepSentence(java.lang.String sentence,
                                             java.lang.String to,
                                             java.lang.String[] cos,
                                             java.lang.String po,
                                             java.lang.String[][] nes)
Prepares a sentence for pattern extraction.

Parameters:
sentence - input sentence
to - the TARGET object of the question
cos - the CONTEXT objects of the question
po - the answer to the question
nes - the NEs in the sentence
Returns:
sentence ready for pattern extraction or null, if there is no TARGET or PROPERTY object in the input sentence

extractPatterns

private static java.lang.String[] extractPatterns(java.lang.String sentence)
Extract basic answer patterns from the sentence.

Parameters:
sentence - input sentence
Returns:
basic answer patterns

generalizePatterns

private static java.lang.String[] generalizePatterns(java.lang.String[] patterns,
                                                     java.lang.String prop)
Generates more generic patterns from the initial patterns.

Parameters:
patterns - initial patterns
prop - PROPERTY that the patterns extract
Returns:
more generic patterns

extract

public static void extract(Result result,
                           java.lang.String as)
Extracts answer patterns from the answer string of a Result object and adds them to the AnswerPatternFilter.

Parameters:
result - Result object
as - the answer to the question