public void process(JCas jCas) throws AnalysisEngineProcessException { TriageScore doc = JCasUtil.selectSingle(jCas, TriageScore.class); String code = doc.getInOutCode(); File outFile = new File(baseData.getPath() + "/" + code + ".txt"); try { PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(outFile, true))); out.print(doc.getVpdmfId() + " "); for (Sentence sentence : JCasUtil.select(jCas, Sentence.class)) { List<Token> tokens = JCasUtil.selectCovered(jCas, Token.class, sentence); if (tokens.size() <= 0) { continue; } List<String> tokenStrings = JCasUtil.toText(tokens); for (int i = 0; i < tokens.size(); i++) { out.print(tokenStrings.get(i) + " "); } } out.print("\n"); out.close(); } catch (IOException e) { throw new AnalysisEngineProcessException(e); } }
@Override public ClassificationTEDecision process(JCas jcas) throws EDAException, ComponentException { Pair pair = JCasUtil.selectSingle(jcas, Pair.class); // Compute similarity scores with all components List<Double> scores = new ArrayList<Double>(); for (ScoringComponent component : getComponents()) { Vector<Double> subscores = component.calculateScores(jcas); scores.addAll(subscores); } // If multiple components have been used, we use the highest score // to determine the Entailment/NonEntailment relationship. // This is intended for illustration purposes only, as the similarity // scores are not normally distributed. double maxScore = Collections.max(scores); DecisionLabel label; if (maxScore >= threshold) label = DecisionLabel.Entailment; else label = DecisionLabel.NonEntailment; return new ClassificationTEDecision(label, scores.get(0), pair.getPairID()); }