info.ephyra.questionanalysis
Class QuestionPattern

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

public class QuestionPattern
extends java.lang.Object

A QuestionPattern is applied to a question to determine the TARGET of the question, CONTEXT information and the PROPERTY the question asks for.

Version:
2006-04-20
Author:
Nico Schlaefer

Field Summary
private  int[] contextIDs
          IDs of 0 to n groups that represent the CONTEXT of the question.
private static int MAX_CONTEXT
          Maximum length of a CONTEXT object in tokens.
private static int MAX_TARGET
          Maximum length of a TARGET object in tokens.
private  java.util.regex.Pattern pattern
          The Pattern that is applied to a question string.
private  java.lang.String property
          The PROPERTY that a question which matches this pattern asks for.
private  int targetID
          ID of the group that represents the TARGET of the question.
 
Constructor Summary
QuestionPattern(java.lang.String expr, java.lang.String prop)
          Creates a QuestionPattern 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
 
Method Summary
 QuestionInterpretation apply(java.lang.String qn, java.lang.String stemmed)
          Applies the pattern to a question.
private  QuestionInterpretation ensureNounPhrases(java.lang.String qn, QuestionInterpretation qi)
          Ensures that the TARGET and CONTEXT objects are noun phrases and splits the objects along prepositions and punctuation marks.
private  java.lang.String formatObject(java.lang.String object)
          Formats the extracted TARGET and CONTEXT objects.
 java.lang.String getProperty()
          Returns the PROPERTY that a question which matches the pattern asks for.
private  java.lang.String replaceContextTags(java.lang.String expr)
          Sets the contextIDs field and replaces the CONTEXT tags by capturing groups.
private  java.lang.String replaceTargetTag(java.lang.String expr)
          Sets the targetID field and replaces the TARGET tag by a capturing group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_TARGET

private static final int MAX_TARGET
Maximum length of a TARGET object in tokens.

See Also:
Constant Field Values

MAX_CONTEXT

private static final int MAX_CONTEXT
Maximum length of a CONTEXT object in tokens.

See Also:
Constant Field Values

pattern

private java.util.regex.Pattern pattern
The Pattern that is applied to a question string.


property

private java.lang.String property
The PROPERTY that a question which matches this pattern asks for.


targetID

private int targetID
ID of the group that represents the TARGET of the question.


contextIDs

private int[] contextIDs
IDs of 0 to n groups that represent the CONTEXT of the question.

Constructor Detail

QuestionPattern

public QuestionPattern(java.lang.String expr,
                       java.lang.String prop)
Creates a QuestionPattern from a descriptor that is a regular expression but additionally contains the following tags:

Parameters:
expr - pattern descriptor
prop - PROPERTY that a question which matches the pattern asks for
Method Detail

replaceTargetTag

private java.lang.String replaceTargetTag(java.lang.String expr)
Sets the targetID field and replaces the TARGET tag by a capturing group.

Parameters:
expr - pattern descriptor
Returns:
descriptor without TARGET tag

replaceContextTags

private java.lang.String replaceContextTags(java.lang.String expr)
Sets the contextIDs field and replaces the CONTEXT tags by capturing groups.

Parameters:
expr - pattern descriptor
Returns:
descriptor without CONTEXT tags

ensureNounPhrases

private QuestionInterpretation ensureNounPhrases(java.lang.String qn,
                                                 QuestionInterpretation qi)
Ensures that the TARGET and CONTEXT objects are noun phrases and splits the objects along prepositions and punctuation marks.

Parameters:
qn - normalized question string
qi - question interpretation
Returns:
modified question interpretation

formatObject

private java.lang.String formatObject(java.lang.String object)
Formats the extracted TARGET and CONTEXT objects.

Parameters:
object - TARGET or CONTEXT object
Returns:
formatted object

getProperty

public java.lang.String getProperty()
Returns the PROPERTY that a question which matches the pattern asks for.

Returns:
the PROPERTY

apply

public QuestionInterpretation apply(java.lang.String qn,
                                    java.lang.String stemmed)
Applies the pattern to a question. If the question matches the pattern, a QuestionInterpretation is returned, else null.

Parameters:
qn - normalized question string
stemmed - stemmed question string
Returns:
interpretation of the question or null, if the question does not match the pattern