Search in sources :

Example 6 with AnswerPattern

use of info.ephyra.answerselection.AnswerPattern in project lucida by claritylab.

the class AnswerPatternFilter method dropLowSupport.

/**
	 * Drops answer patterns that have a support of <code>supportThresh</code>
	 * or less.
	 * 
	 * @param supportThresh the support threshold
	 */
public static void dropLowSupport(float supportThresh) {
    // for each PROPERTY
    for (String prop : props.keySet()) {
        HashSet<AnswerPattern> patterns = props.get(prop);
        int n = nOfPassages.get(prop);
        HashSet<AnswerPattern> remaining = new HashSet<AnswerPattern>();
        // check the threshold for each answer pattern
        for (AnswerPattern pattern : patterns) if ((pattern.getCorrect() / (float) n) >= supportThresh)
            remaining.add(pattern);
        props.put(prop, remaining);
    }
}
Also used : AnswerPattern(info.ephyra.answerselection.AnswerPattern) HashSet(java.util.HashSet)

Example 7 with AnswerPattern

use of info.ephyra.answerselection.AnswerPattern in project lucida by claritylab.

the class AnswerPatternFilter method addPattern.

/**
	 * Adds an answer pattern for a specific PROPERTY.
	 * 
	 * @param expr pattern descriptor
	 * @param prop PROPERTY that the pattern extracts
	 * @return true, iff a new pattern was added
	 */
public static boolean addPattern(String expr, String prop) {
    // get the answer patterns for the specified PROPERTY
    HashSet<AnswerPattern> patterns = props.get(prop);
    if (patterns == null) {
        // new PROPERTY
        patterns = new HashSet<AnswerPattern>();
        props.put(prop, patterns);
        nOfPassages.put(prop, 0);
    }
    // if the pattern is not in the set, add it
    boolean added = patterns.add(new AnswerPattern(expr, prop));
    // print out new patterns
    if (added)
        MsgPrinter.printStatusMsg(prop + ": " + expr);
    return added;
}
Also used : AnswerPattern(info.ephyra.answerselection.AnswerPattern)

Aggregations

AnswerPattern (info.ephyra.answerselection.AnswerPattern)7 File (java.io.File)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 QuestionInterpretation (info.ephyra.questionanalysis.QuestionInterpretation)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 PrintWriter (java.io.PrintWriter)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1