/** * Returns the pair ID from a JCas created by an EOP LAP. * @param jcas * @return */ public static String getPairIdFromCas(JCas jcas) { Pair pairAnno = JCasUtil.selectSingle(jcas, Pair.class); return pairAnno.getPairID(); } }
Text t = new Text(textView); t.setBegin(0); t.setEnd(text.length()); t.addToIndexes(); Hypothesis h = new Hypothesis(hypoView); h.setBegin(0); h.setEnd(hypothesis.length()); h.addToIndexes(); Pair p = new Pair(aJCas); p.setText(t); // points T & H p.setHypothesis(h); p.setPairID(pairId); p.setGoldAnswer(goldAnswer.toUpperCase()); p.addToIndexes(); EntailmentMetadata m = new EntailmentMetadata(aJCas); m.setLanguage(this.languageIdentifier); m.setTask(task); m.addToIndexes();
/** * @param aCas * the <code>JCas</code> object * @return return whether it is an identical pair or not */ protected final boolean isIdenticalPair(JCas aCas) { FSIterator<TOP> iter = aCas.getJFSIndexRepository().getAllIndexedFS( Pair.type); if (iter.hasNext()) { Pair p = (Pair) iter.next(); String text = p.getText().getCoveredText(); String hypothesis = p.getHypothesis().getCoveredText(); if (text.trim().equals(hypothesis.trim())) { return true; } } // empty pair return false; }
aOut.printf("Language:%s\nTask:%s\n", m.getLanguage(), m.getTask()); aOut.printf("Origin:%s\nChannel:%s\n", m.getOrigin(), m.getChannel()); aOut.printf("TextDocumentID:%s\nTextCollectionID:%s\n", m.getTextDocumentID(), m.getTextCollectionID()); aOut.printf("HypothesisDocumentID:%s\nHypothesisCollectionID:%s\n", m.getHypothesisDocumentID(), m.getHypothesisCollectionID()); if (aOut != null) aOut.printf("PairID: %s\n", p.getPairID()); aOut.printf("GoldAnswer: %s\n", p.getGoldAnswer()); text = p.getText().getCoveredText(); hypothesis = p.getHypothesis().getCoveredText();
Text textAnno = pairAnno.getText(); Hypothesis hypothesisAnno = pairAnno.getHypothesis(); JCas textView = jcas.getView(LAP_ImplBase.TEXTVIEW); JCas hypothesisView = jcas.getView(LAP_ImplBase.HYPOTHESISVIEW); String stringID = pairAnno.getPairID(); try { id = Integer.valueOf(stringID); String goldString = pairAnno.getGoldAnswer(); if (goldString != null) { DecisionLabel goldDecision = DecisionLabel.getLabelFor(goldString); TextHypothesisPair pair = new TextHypothesisPair(textAnno.getCoveredText(), hypothesisAnno.getCoveredText(), id, gold, null); return new PairData(pair, textTrees, hypothesisTree, mapTreesToSentences, coreferenceInformation);
/** * @param aCas the <code>JCas</code> object * * @return if the T-H pair contains the gold answer, return it; otherwise return null */ private String getGoldLabel(JCas aCas) { FSIterator<TOP> pairIter = aCas.getJFSIndexRepository() .getAllIndexedFS(Pair.type); Pair p = (Pair) pairIter.next(); if (null == p.getGoldAnswer() || p.getGoldAnswer().equals("") || p.getGoldAnswer().equals("ABSTAIN")) { return null; } else { return p.getGoldAnswer(); } }
private void prepareCacheContent(JCas aJCas, String input) throws LAPException { // generate views and set SOFA JCas textView = null; JCas hypoView = null; try { textView = aJCas.createView(LAP_ImplBase.TEXTVIEW); hypoView = aJCas.createView(LAP_ImplBase.HYPOTHESISVIEW); } catch (CASException e) { throw new LAPException("Unble to create new views", e); } textView.setDocumentLanguage(this.languageId); hypoView.setDocumentLanguage(this.languageId); textView.setDocumentText(input); hypoView.setDocumentText(input); // annotate Text (on TextView) Text t = new Text(textView); t.setBegin(0); t.setEnd(input.length()); t.addToIndexes(); // annotate Hypothesis (on HypothesisView) Hypothesis h = new Hypothesis(hypoView); h.setBegin(0); h.setEnd(input.length()); h.addToIndexes(); // okay. now call underlyingLAP to annotate underlyingLAP.addAnnotationOn(aJCas, LAP_ImplBase.TEXTVIEW); underlyingLAP.addAnnotationOn(aJCas, LAP_ImplBase.HYPOTHESISVIEW); // done. aJCas is updated to be used for cache. actualCall ++; }
/** * @param aCas * the <code>JCas</code> object * @return return whether it is an identical pair or not */ protected final boolean isIdenticalPair(JCas aCas) { FSIterator<TOP> iter = aCas.getJFSIndexRepository().getAllIndexedFS( Pair.type); if (iter.hasNext()) { Pair p = (Pair) iter.next(); String text = p.getText().getCoveredText(); String hypothesis = p.getHypothesis().getCoveredText(); if (text.trim().equals(hypothesis.trim())) { return true; } } // empty pair return false; }
/** * @param aCas * the <code>JCas</code> object * @return return the pairID of the T-H pair */ protected final String getPairID(JCas aCas) { FSIterator<TOP> pairIter = aCas.getJFSIndexRepository() .getAllIndexedFS(Pair.type); Pair p = (Pair) pairIter.next(); return p.getPairID(); }
/** * @param aCas * input T-H pair * @return if the pair contains the gold answer, return it; otherwise, * return null */ protected String getGoldLabel(JCas aCas) { FSIterator<TOP> pairIter = aCas.getJFSIndexRepository() .getAllIndexedFS(Pair.type); Pair p = (Pair) pairIter.next(); if (null == p.getGoldAnswer() || p.getGoldAnswer().equals("") || p.getGoldAnswer().equals("ABSTAIN")) { return null; } else { return p.getGoldAnswer(); } }
/** * @param aCas * the <code>JCas</code> object * @return return the pairID of the T-H pair */ protected final String getPairID(JCas aCas) { FSIterator<TOP> pairIter = aCas.getJFSIndexRepository() .getAllIndexedFS(Pair.type); Pair p = (Pair) pairIter.next(); return p.getPairID(); }
/** * @param aCas * the <code>JCas</code> object * @return if the T-H pair contains the gold answer, return it; otherwise, * return null */ public static String getGoldLabel(JCas aCas) { FSIterator<TOP> pairIter = aCas.getJFSIndexRepository() .getAllIndexedFS(Pair.type); Pair p = (Pair) pairIter.next(); if (null == p.getGoldAnswer() || p.getGoldAnswer().equals("") || p.getGoldAnswer().equals("ABSTAIN")) { return null; } else { return p.getGoldAnswer(); } }
/** * @param aCas * input T-H pair * @return return the pairID of the pair */ protected String getPairID(JCas aCas) { FSIterator<TOP> pairIter = aCas.getJFSIndexRepository() .getAllIndexedFS(Pair.type); Pair p = (Pair) pairIter.next(); return p.getPairID(); }
/** * @param aCas * the <code>JCas</code> object * @return if the T-H pair contains the gold answer, return it; otherwise, * return null */ protected final String getGoldLabel(JCas aCas) { FSIterator<TOP> pairIter = aCas.getJFSIndexRepository() .getAllIndexedFS(Pair.type); Pair p = (Pair) pairIter.next(); if (null == p.getGoldAnswer() || p.getGoldAnswer().equals("") || p.getGoldAnswer().equals("ABSTAIN")) { return null; } else { return p.getGoldAnswer(); } }
/** * @param aCas * the <code>JCas</code> object * @return return the pairID of the T-H pair */ public static String getPairID(JCas aCas) { FSIterator<TOP> pairIter = aCas.getJFSIndexRepository() .getAllIndexedFS(Pair.type); Pair p = (Pair) pairIter.next(); return p.getPairID(); }
/** * @param aCas * the <code>JCas</code> object * @return if the T-H pair contains the gold answer, return it; otherwise, * return null */ protected final String getGoldLabel(JCas aCas) { FSIterator<TOP> pairIter = aCas.getJFSIndexRepository() .getAllIndexedFS(Pair.type); Pair p = (Pair) pairIter.next(); if (null == p.getGoldAnswer() || p.getGoldAnswer().equals("") || p.getGoldAnswer().equals("ABSTAIN")) { return null; } else { return p.getGoldAnswer(); } }
/** * @param aCas the <code>JCas</code> object * * @return return the pairID of the T-H pair */ private String getPairID(JCas aCas) { FSIterator<TOP> pairIter = aCas.getJFSIndexRepository().getAllIndexedFS(Pair.type); Pair p = (Pair) pairIter.next(); return p.getPairID(); }
/** * Puts the entailment annotations calculating of each of the pair T and H * of the specified list of Cas into the entailmentValueList list. * Each of the Cas of the list contains a single pair T-H. * * @param jcas the list of CAS * @aram entailmentValueList the list of the entailment annotations * * @throws Exception */ protected void getEntailmentAnnotation(JCas jcas, List<String> entailmentValueList) throws Exception { try { Pair p = null; FSIterator<TOP> pairIter = jcas.getJFSIndexRepository().getAllIndexedFS(Pair.type); p = (Pair) pairIter.next(); String goldAnswer = p.getGoldAnswer(); entailmentValueList.add(goldAnswer); } catch(Exception e) { throw e; } }
/** * Returns the pair identifier of the pair contained in the specified CAS * * @param jcas the CAS * * @return the pair identifier */ protected String getPairId(JCas jcas) { FSIterator<TOP> pairIter = jcas.getJFSIndexRepository().getAllIndexedFS(Pair.type); Pair p = null; if (pairIter.hasNext()) p = (Pair)pairIter.next(); if (p != null) return p.getPairID(); return null; }