info.ephyra.patternlearning
Class PatternLearner

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

public class PatternLearner
extends java.lang.Object

A pattern learning tool for Ephyra.

Version:
2006-04-04
Author:
Nico Schlaefer

Field Summary
private static java.util.Hashtable<java.lang.String,java.lang.String> ass
          Maps questions or query strings to answers.
private static float CONFIDENCE_THRESH
          Confidence threshold for answer patterns.
private static java.lang.String[] qss
          Question strings.
private static java.util.Hashtable<java.lang.String,java.lang.String> regexs
          Maps questions or query strings to patterns for correct answers.
private static float SUPPORT_THRESH
          Support threshold for answer patterns.
 
Constructor Summary
PatternLearner()
           
 
Method Summary
static boolean assess()
          Loads target-context-answer-regex tuples and answer patterns from resource files, forms queries from the tuples, fetches text passages, assesses the answer patterns on the text passages and writes them to resource files.
private static void assessPatterns(Result[] results)
          Assesses the answer patterns on the text passages in the Result objects.
static boolean extract()
          Loads target-context-answer-regex tuples from resource files, forms queries, fetches text passages, extracts answer patterns and writes them to resource files.
private static void extractPatterns(Result[] results)
          Extracts answer patterns from the text passages in the search results.
private static Result[] fetchPassages(Query[] queries)
          Fetches text passages from knowledge sources.
static boolean filter()
          Loads answer patterns from resource files, drops patterns with a low support or confidence and writes the remaining patterns back to resource files.
private static void filterPatterns()
          Drops answer patterns that have a low support or confidence.
private static Query[] formQueries(java.lang.String dir)
          Loads target-context-answer-regex tuples from resource files and forms queries.
static void init()
          Initializes the pattern learning tool.
static boolean interpret(java.lang.String qFile, java.lang.String aFile, java.lang.String pFile)
          Loads the TREC data, interprets the questions and writes target-context-answer-regex tuples to files.
private static boolean interpretQuestions(java.lang.String dir)
          Interprets the questions and writes target-context-answer-regex tuples to resource files.
private static boolean loadPatterns(java.lang.String dir)
          Loads answer patterns from resource files.
private static void loadTRECData(java.lang.String qFile, java.lang.String aFile, java.lang.String pFile)
          Loads the questions, answers and patterns from TREC files.
static void main(java.lang.String[] args)
          Entry point of the program.
private static boolean saveInterpretation(java.lang.String dir, QuestionInterpretation qi, java.lang.String as, java.lang.String regex)
          Saves a question interpretation, an answer string and a regular expression that describes a correct answer to a file.
private static boolean savePatterns(java.lang.String dir)
          Saves answer patterns to resource files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUPPORT_THRESH

private static final float SUPPORT_THRESH
Support threshold for answer patterns.

See Also:
Constant Field Values

CONFIDENCE_THRESH

private static final float CONFIDENCE_THRESH
Confidence threshold for answer patterns.

See Also:
Constant Field Values

qss

private static java.lang.String[] qss
Question strings.


ass

private static java.util.Hashtable<java.lang.String,java.lang.String> ass
Maps questions or query strings to answers.


regexs

private static java.util.Hashtable<java.lang.String,java.lang.String> regexs
Maps questions or query strings to patterns for correct answers.

Constructor Detail

PatternLearner

public PatternLearner()
Method Detail

loadTRECData

private static void loadTRECData(java.lang.String qFile,
                                 java.lang.String aFile,
                                 java.lang.String pFile)
Loads the questions, answers and patterns from TREC files.

Parameters:
qFile - name of the file containing the questions
aFile - name of the file containing the answers or an empty string
pFile - name of the file containing the patterns or an empty string

interpretQuestions

private static boolean interpretQuestions(java.lang.String dir)
Interprets the questions and writes target-context-answer-regex tuples to resource files.

Parameters:
dir - target directory
Returns:
true, iff the interpretations could be written to resource files

saveInterpretation

private static boolean saveInterpretation(java.lang.String dir,
                                          QuestionInterpretation qi,
                                          java.lang.String as,
                                          java.lang.String regex)
Saves a question interpretation, an answer string and a regular expression that describes a correct answer to a file.

Parameters:
dir - target directory
qi - question interpretation
as - answer string
regex - regular expression
Returns:
true, iff the tuple could be saved

formQueries

private static Query[] formQueries(java.lang.String dir)
Loads target-context-answer-regex tuples from resource files and forms queries.

Parameters:
dir - directory containing the target-context-answer-regex tuples
Returns:
queries formed from the tuples

fetchPassages

private static Result[] fetchPassages(Query[] queries)
Fetches text passages from knowledge sources.

Parameters:
queries - the queries sent to the searchers
Returns:
results from the searchers

extractPatterns

private static void extractPatterns(Result[] results)
Extracts answer patterns from the text passages in the search results.

Parameters:
results - search results

savePatterns

private static boolean savePatterns(java.lang.String dir)
Saves answer patterns to resource files.

Parameters:
dir - target directory
Returns:
true, iff the answer patterns could be saved

loadPatterns

private static boolean loadPatterns(java.lang.String dir)
Loads answer patterns from resource files.

Parameters:
dir - directory containing the answer patterns
Returns:
true, iff the answer patterns could be loaded

assessPatterns

private static void assessPatterns(Result[] results)
Assesses the answer patterns on the text passages in the Result objects.

Parameters:
results - search results

filterPatterns

private static void filterPatterns()
Drops answer patterns that have a low support or confidence.


init

public static void init()
Initializes the pattern learning tool.


interpret

public static boolean interpret(java.lang.String qFile,
                                java.lang.String aFile,
                                java.lang.String pFile)
Loads the TREC data, interprets the questions and writes target-context-answer-regex tuples to files.

Parameters:
qFile - name of the file containing the questions
aFile - name of the file containing the answers or an empty string
pFile - name of the file containing the patterns or an empty string
Returns:
true, iff the TREC data could be interpreted

extract

public static boolean extract()
Loads target-context-answer-regex tuples from resource files, forms queries, fetches text passages, extracts answer patterns and writes them to resource files.

Returns:
true, iff the answer patterns could be extracted

assess

public static boolean assess()
Loads target-context-answer-regex tuples and answer patterns from resource files, forms queries from the tuples, fetches text passages, assesses the answer patterns on the text passages and writes them to resource files.

Returns:
true, iff the answer patterns could be assessed

filter

public static boolean filter()
Loads answer patterns from resource files, drops patterns with a low support or confidence and writes the remaining patterns back to resource files.

Returns:
true, iff the answer patterns could be filtered

main

public static void main(java.lang.String[] args)

Entry point of the program.

Learns and assesses answer patterns using questions and patterns from the TREC QA track as training data.

Parameters:
args - argument 1: name of the question file
argument 2: name of the answer file
argument 3: name of the file containing the patterns