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;
}
}
Aggregations