info.ephyra.questionanalysis.atype
Class QuestionClassifier

java.lang.Object
  extended by info.ephyra.questionanalysis.atype.QuestionClassifier
Direct Known Subclasses:
HybridQuestionClassifier, RuleBasedQuestionClassifier, TrainedQuestionClassifier

public abstract class QuestionClassifier
extends java.lang.Object

A class for classifying questions in terms of their expected answer type. This abstract class contains most of the accessor methods for getting a question's classification results, while the details of exactly how that classification is determined (see the classify method) is left to the subclasses.

Version:
2008-02-10
Author:
Justin Betteridge

Field Summary
protected  FeatureExtractor extractor
           
protected  boolean isInitialized
           
protected  edu.cmu.lti.util.Pair<edu.cmu.lti.javelin.util.Language,edu.cmu.lti.javelin.util.Language> languagePair
           
private static org.apache.log4j.Logger log
           
 
Constructor Summary
QuestionClassifier()
           
 
Method Summary
abstract  java.util.List<AnswerType> classify(edu.cmu.minorthird.classify.Instance instance)
          Classifies a question, represented by an Instance, in terms of its expected answer type.
 void classifySet(java.lang.String filename)
           
 void evaluate(java.lang.String testSetFileName)
          Evaluates classification accuracy on a given test set.
 java.util.List<AnswerType> getAnswerTypes(java.util.List<edu.cmu.lti.javelin.qa.Term> terms, java.lang.String parseTreeStr)
          Classifies the question represented by the given List of Terms and parse tree as having a particular answer type and possibly subtype.
 java.util.List<AnswerType> getAnswerTypes(java.lang.String question)
          Classifies the question represented by the given String as having a particular answer type and possibly subtype.
 java.util.List<AnswerType> getAnswerTypes(java.lang.String question, java.lang.String parseTreeStr)
          Classifies the question represented by the given String and parse tree as having a particular answer type and possibly subtype.
 edu.cmu.lti.util.Pair<edu.cmu.lti.javelin.util.Language,edu.cmu.lti.javelin.util.Language> getLanguagePair()
           
 void initialize()
          Initializes the FeatureExtractor.
 boolean isInitialized()
           
 void setInitialized(boolean isInitialized)
           
 void setLanguagePair(edu.cmu.lti.util.Pair<edu.cmu.lti.javelin.util.Language,edu.cmu.lti.javelin.util.Language> languagePair)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.log4j.Logger log

extractor

protected FeatureExtractor extractor

isInitialized

protected boolean isInitialized

languagePair

protected edu.cmu.lti.util.Pair<edu.cmu.lti.javelin.util.Language,edu.cmu.lti.javelin.util.Language> languagePair
Constructor Detail

QuestionClassifier

public QuestionClassifier()
Method Detail

initialize

public void initialize()
                throws java.lang.Exception
Initializes the FeatureExtractor.

Throws:
java.lang.Exception - if one of the required input properties is not defined

isInitialized

public boolean isInitialized()
Returns:
the isInitialized

setInitialized

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

setLanguagePair

public void setLanguagePair(edu.cmu.lti.util.Pair<edu.cmu.lti.javelin.util.Language,edu.cmu.lti.javelin.util.Language> languagePair)
Parameters:
languagePair - the languagePair to set

getLanguagePair

public edu.cmu.lti.util.Pair<edu.cmu.lti.javelin.util.Language,edu.cmu.lti.javelin.util.Language> getLanguagePair()
Returns:
the languagePair

getAnswerTypes

public java.util.List<AnswerType> getAnswerTypes(java.util.List<edu.cmu.lti.javelin.qa.Term> terms,
                                                 java.lang.String parseTreeStr)
                                          throws java.lang.Exception
Classifies the question represented by the given List of Terms and parse tree as having a particular answer type and possibly subtype.

Parameters:
terms - the Terms that make up the question to classify
parseTreeStr - the syntactic parse tree of the question, in String format
Returns:
the candidate answer type / subtypes.
Throws:
java.lang.Exception

getAnswerTypes

public java.util.List<AnswerType> getAnswerTypes(java.lang.String question,
                                                 java.lang.String parseTreeStr)
                                          throws java.lang.Exception
Classifies the question represented by the given String and parse tree as having a particular answer type and possibly subtype.

Parameters:
question - the question to classify
parseTreeStr - the syntactic parse tree of the question, in String format
Returns:
the candidate answer type / subtypes.
Throws:
java.lang.Exception

getAnswerTypes

public java.util.List<AnswerType> getAnswerTypes(java.lang.String question)
                                          throws java.lang.Exception
Classifies the question represented by the given String as having a particular answer type and possibly subtype.

Parameters:
question - the question to classify
Returns:
the candidate answer type / subtypes.
Throws:
java.lang.Exception

classify

public abstract java.util.List<AnswerType> classify(edu.cmu.minorthird.classify.Instance instance)
Classifies a question, represented by an Instance, in terms of its expected answer type. Multiple AnswerTypes may be returned, ranked by their associated score, or probability of being ccrrect. The source object associated with the Instance that is returned by Instance.getSource() must be the original question, in String form.

Parameters:
instance - the Instance to be classified.
Returns:
a list of AnswerTypes, ranked by their associated score, or probability of being ccrrect.

evaluate

public void evaluate(java.lang.String testSetFileName)
              throws java.lang.Exception
Evaluates classification accuracy on a given test set.

Parameters:
testSetFileName - the name of the file containing the test set to evaluate against
Throws:
java.lang.Exception

classifySet

public void classifySet(java.lang.String filename)