Search in sources :

Example 11 with Term

use of edu.cmu.lti.javelin.qa.Term in project lucida by claritylab.

the class EnglishFeatureExtractor method createInstance.

public Instance createInstance(String question) {
    String[] tokens = question.split("\\s+");
    List<String> words = new ArrayList<String>();
    for (String token : tokens) words.add(token);
    try {
        String parse = StanfordParser.parse(question);
        return createInstance(question, parse);
    } catch (Exception e) {
        log.error("Failed to parse question, using only word-level features.", e);
        List<Term> terms = new ArrayList<Term>();
        for (String word : words) terms.add(new Term(0, 0, word));
        MutableInstance instance = new MutableInstance(question);
        addWordLevelFeatures(instance, terms, null);
        return instance;
    }
}
Also used : ArrayList(java.util.ArrayList) MutableInstance(edu.cmu.minorthird.classify.MutableInstance) ArrayList(java.util.ArrayList) List(java.util.List) Term(edu.cmu.lti.javelin.qa.Term)

Aggregations

Term (edu.cmu.lti.javelin.qa.Term)11 Tree (edu.cmu.lti.chineseNLP.util.Tree)6 MutableInstance (edu.cmu.minorthird.classify.MutableInstance)3 ArrayList (java.util.ArrayList)3 Feature (edu.cmu.minorthird.classify.Feature)2 IOException (java.io.IOException)2 Matcher (java.util.regex.Matcher)2 Instance (edu.cmu.minorthird.classify.Instance)1 List (java.util.List)1 IndexWord (net.didion.jwnl.data.IndexWord)1