info.ephyra.questionanalysis
Class QuestionInterpreter

java.lang.Object
  extended by info.ephyra.questionanalysis.QuestionInterpreter

public class QuestionInterpreter
extends java.lang.Object

The QuestionInterpreter parses a question and determines the TARGET, the CONTEXT and the PROPERTY it asks for.

Version:
2005-11-09
Author:
Nico Schlaefer

Field Summary
private static java.util.Hashtable<java.lang.String,java.lang.String> answerTemplates
          For each PROPERTY a template for an answer string.
private static java.util.Hashtable<java.lang.String,HashDictionary> keywords
          For each PROPERTY a dictionary of keywords.
private static java.util.ArrayList<QuestionPattern> questionPatterns
          The patterns that are applied to a question.
private static java.util.Hashtable<java.lang.String,java.lang.String> questionTemplates
          For each PROPERTY a template for a question asking for it.
 
Constructor Summary
QuestionInterpreter()
           
 
Method Summary
private static void addKeywords(java.lang.String expr, java.lang.String prop)
          Adds the keywords in a descriptor of a question pattern to the dictionary for the respective PROPERTY.
static java.lang.String getAnswer(java.lang.String po, java.lang.String prop)
          Returns an answer string that expresses that the property object is an instance of the specified property or null if no answer template is available for the property.
static java.lang.String getQuestion(java.lang.String to, java.lang.String prop)
          Returns a question string that asks for the specified property of the target object or null if no question template is available for the property.
static QuestionInterpretation[] interpret(java.lang.String qn, java.lang.String stemmed)
          Interprets a question by applying the question patterns and returns the interpretations of minimal length.
static boolean loadPatterns(java.lang.String dir)
          Loads the question patterns from a directory of PROPERTY files.
static boolean lookupKeyword(java.lang.String word, java.lang.String prop)
          Looks up a word in the dictionary for the given PROPERTY.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

questionPatterns

private static java.util.ArrayList<QuestionPattern> questionPatterns
The patterns that are applied to a question.


keywords

private static java.util.Hashtable<java.lang.String,HashDictionary> keywords
For each PROPERTY a dictionary of keywords.


questionTemplates

private static java.util.Hashtable<java.lang.String,java.lang.String> questionTemplates
For each PROPERTY a template for a question asking for it.


answerTemplates

private static java.util.Hashtable<java.lang.String,java.lang.String> answerTemplates
For each PROPERTY a template for an answer string.

Constructor Detail

QuestionInterpreter

public QuestionInterpreter()
Method Detail

addKeywords

private static void addKeywords(java.lang.String expr,
                                java.lang.String prop)
Adds the keywords in a descriptor of a question pattern to the dictionary for the respective PROPERTY.

Parameters:
expr - pattern descriptor
prop - PROPERTY the question pattern belongs to

loadPatterns

public static boolean loadPatterns(java.lang.String dir)
Loads the question patterns from a directory of PROPERTY files. Each file contains a list of pattern descriptors. Their format is described in the documentation of the class QuestionPattern.

Parameters:
dir - directory of the question patterns
Returns:
true, iff the question patterns were loaded successfully

interpret

public static QuestionInterpretation[] interpret(java.lang.String qn,
                                                 java.lang.String stemmed)
Interprets a question by applying the question patterns and returns the interpretations of minimal length.

Parameters:
qn - normalized question string
stemmed - stemmed question string
Returns:
array of interpretations or an empty array, if there was no matching question pattern

lookupKeyword

public static boolean lookupKeyword(java.lang.String word,
                                    java.lang.String prop)
Looks up a word in the dictionary for the given PROPERTY.

Parameters:
word - the word to be looked up
prop - the PROPERTY
Returns:
true, iff word is in the dictionary for prop

getQuestion

public static java.lang.String getQuestion(java.lang.String to,
                                           java.lang.String prop)
Returns a question string that asks for the specified property of the target object or null if no question template is available for the property.

Parameters:
to - target object
prop - property
Returns:
question string or null

getAnswer

public static java.lang.String getAnswer(java.lang.String po,
                                         java.lang.String prop)
Returns an answer string that expresses that the property object is an instance of the specified property or null if no answer template is available for the property.

Parameters:
po - property object
prop - property
Returns:
answer string or null