info.ephyra.questionanalysis.atype
Class FocusFinder

java.lang.Object
  extended by info.ephyra.questionanalysis.atype.FocusFinder

public class FocusFinder
extends java.lang.Object

Finder of the focus word, or target word, of a question.

Version:
2008-02-10
Author:
Justin Betteridge

Field Summary
private static boolean isInitialized
           
private static org.apache.log4j.Logger log
           
private static java.util.List<edu.cmu.lti.chineseNLP.util.Tree> treeTemplates
           
private static java.lang.String treeTemplatesFile
           
private static java.lang.String[] whLabels
           
 
Constructor Summary
FocusFinder()
           
 
Method Summary
static edu.cmu.lti.chineseNLP.util.Tree findFocusNode(edu.cmu.lti.chineseNLP.util.Tree tree)
          Finds the focus, or target, word of a question using the specified tree templates and default rules that look for question words.
static edu.cmu.lti.javelin.qa.Term findFocusTerm(java.util.List<edu.cmu.lti.javelin.qa.Term> terms)
          Given a list of Terms, builds a parse tree using Charniak's parser, and then uses the resulting parse tree to find the focus words.
static edu.cmu.lti.javelin.qa.Term findFocusTerm(java.lang.String question)
          Given a sentence, builds a parse tree using Charniak's parser, and then uses the resulting parse tree to find the focus words.
static edu.cmu.lti.javelin.qa.Term findFocusTerm(edu.cmu.lti.chineseNLP.util.Tree tree)
          Finds the focus word, given a Tree.
static java.lang.String findFocusWord(java.util.List<edu.cmu.lti.javelin.qa.Term> terms)
          Given a list of Terms, builds a parse tree using Charniak's parser, and then uses the resulting parse tree to find the focus words.
static java.lang.String findFocusWord(java.lang.String question)
          Given a sentence, builds a parse tree using Charniak's parser, and then uses the resulting parse tree to find the focus words.
static java.lang.String findFocusWord(edu.cmu.lti.chineseNLP.util.Tree tree)
          Finds the focus word, given a Tree.
static edu.cmu.lti.chineseNLP.util.Tree getHeadWordOrPhrase(edu.cmu.lti.chineseNLP.util.Tree tree)
          Extracts the head word or phrase from the given Tree node, which is assumed to be an NP.
static void initialize()
          Initializes static resources.
static boolean isInitialized()
           
static void main(java.lang.String[] args)
          Extracts and prints out the focus word for each question, given a file of questions.
static void setInitialized(boolean isInitialized)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.log4j.Logger log

isInitialized

private static boolean isInitialized

treeTemplates

private static java.util.List<edu.cmu.lti.chineseNLP.util.Tree> treeTemplates

treeTemplatesFile

private static java.lang.String treeTemplatesFile

whLabels

private static java.lang.String[] whLabels
Constructor Detail

FocusFinder

public FocusFinder()
Method Detail

initialize

public static void initialize()
                       throws java.lang.Exception
Initializes static resources. The input properties which must be defined are:

Throws:
java.lang.Exception - if the required input property is not defined

isInitialized

public static boolean isInitialized()
Returns:
the isInitialized

setInitialized

public static void setInitialized(boolean isInitialized)
Parameters:
isInitialized - the isInitialized to set

findFocusNode

public static edu.cmu.lti.chineseNLP.util.Tree findFocusNode(edu.cmu.lti.chineseNLP.util.Tree tree)
Finds the focus, or target, word of a question using the specified tree templates and default rules that look for question words.

Using the following algorithm:

  1. Look for the head word of a phrase that has a wh-word child and more than one sibling
    • look for the object of a modifying of-PP if the word is "kind" or "type"
  2. Try to extract a node using the specified tree templates in the order they appear in the file
  3. Using only preterminals, look for the last consecutive NN* or JJ that follows a WDT or WP
  4. Using only preterminals, look for the last consecutive NN* that follows the terminals, "how many".
the focus word is returned as soon as one is found.

Parameters:
tree - The syntactic parse tree of the question
Returns:
the focus word, or null if none was found

getHeadWordOrPhrase

public static edu.cmu.lti.chineseNLP.util.Tree getHeadWordOrPhrase(edu.cmu.lti.chineseNLP.util.Tree tree)
Extracts the head word or phrase from the given Tree node, which is assumed to be an NP. Whether a phrase should be the head is determined by looking up in WordNet all the possible phrases that can be constructed from the immediate children of the input Tree and which include the right-most child.

Parameters:
tree - the Tree node from which to extract the head word or phrase

findFocusWord

public static java.lang.String findFocusWord(edu.cmu.lti.chineseNLP.util.Tree tree)
Finds the focus word, given a Tree.

Parameters:
tree - The syntactic parse tree object
Returns:
the focus word as a String or null, if one does not exist

findFocusWord

public static java.lang.String findFocusWord(java.util.List<edu.cmu.lti.javelin.qa.Term> terms)
Given a list of Terms, builds a parse tree using Charniak's parser, and then uses the resulting parse tree to find the focus words.

Parameters:
terms - The list of Terms in the question.
Returns:
the focus word as a String or null, if one does not exist

findFocusWord

public static java.lang.String findFocusWord(java.lang.String question)
Given a sentence, builds a parse tree using Charniak's parser, and then uses the resulting parse tree to find the focus words.

Parameters:
question - the input question
Returns:
the focus word as a String or null, if one does not exist

findFocusTerm

public static edu.cmu.lti.javelin.qa.Term findFocusTerm(java.util.List<edu.cmu.lti.javelin.qa.Term> terms)
Given a list of Terms, builds a parse tree using Charniak's parser, and then uses the resulting parse tree to find the focus words.

Parameters:
terms - The list of Terms in the question.
Returns:
the focus word as a Term or null, if one does not exist

findFocusTerm

public static edu.cmu.lti.javelin.qa.Term findFocusTerm(java.lang.String question)
Given a sentence, builds a parse tree using Charniak's parser, and then uses the resulting parse tree to find the focus words.

Parameters:
question - the input question
Returns:
the focus word as a Term or null, if one does not exist

findFocusTerm

public static edu.cmu.lti.javelin.qa.Term findFocusTerm(edu.cmu.lti.chineseNLP.util.Tree tree)
Finds the focus word, given a Tree.

Parameters:
tree - The syntactic parse tree object
Returns:
the focus word as a Term or null, if one does not exist

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Extracts and prints out the focus word for each question, given a file of questions.

Parameters:
args - command-line args: "<propertiesFile> <inputQuestionsFile>"
Throws:
java.lang.Exception