public static TOP getFS(JCas jcas, int typeID) { Iterator<TOP> it = jcas.getJFSIndexRepository().getAllIndexedFS(typeID); TOP fs = null; if (it.hasNext()) { fs = it.next(); } return fs; }
/** * * @param jcas * the CAS in which we'll store this annotation * @param annotation * the annotation to be stored. Removes any instances of this annotation type fi */ public static void storeAnnotation(JCas jcas, TOP annotation, int typeID) { Iterator<TOP> it = jcas.getJFSIndexRepository().getAllIndexedFS(typeID); while (it.hasNext()) { TOP oldAnnotation = it.next(); oldAnnotation.removeFromIndexes(); } annotation.addToIndexes(); }
/** * * @param jcas * the CAS in which we'll store this annotation * @param fs * the annotation to be stored. Removes any instances of this annotation type fi */ @SuppressWarnings("unchecked") public static <T extends TOP> void storeFS(JCas jcas, T fs) { Iterator<TOP> it = jcas.getJFSIndexRepository().getAllIndexedFS(T.type); while (it.hasNext()) { T oldAnnotation = (T) it.next(); oldAnnotation.removeFromIndexes(); } fs.addToIndexes(); }
/** * @param jcas ye olde jay-cas * @return the Metadata for the given jcas or null if one is not found */ static private Metadata getMetadata( final JCas jcas ) { // TODO I really dislike this index-everything-to-java1 paradigm final FSIterator<TOP> itr = jcas.getJFSIndexRepository().getAllIndexedFS( Metadata.type ); if ( itr == null || !itr.hasNext() ) { return null; } return (Metadata)itr.next(); }
/** * @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 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(); }
/** * @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 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 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(); }
/** * 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; } }
/** * @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 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(); } }
/** * @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 * 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 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 * 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 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; }
/** * 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; }
/** * Stores annotation version as a property JCas object. * * @param jcas */ private void storeAnnotationVersion( JCas jcas ) { FSIterator<TOP> itr = jcas.getJFSIndexRepository().getAllIndexedFS( Pairs.type ); if ( itr == null || !itr.hasNext() ) { return; } Pairs props = (Pairs)itr.next(); // create a new property array that is one item bigger FSArray propArr = props.getPairs(); FSArray newPropArr = new FSArray( jcas, propArr.size() + 1 ); for ( int i = 0; i < propArr.size(); i++ ) { newPropArr.set( i, propArr.get( i ) ); } Pair annotVerProp = new Pair( jcas ); annotVerProp.setAttribute( iv_annotVerPropKey ); annotVerProp.setValue( String.valueOf( iv_annotVer ) ); // add annotation version prop as last item in array newPropArr.set( newPropArr.size() - 1, annotVerProp ); props.setPairs( newPropArr ); }
/** * Stores annotation version as a property JCas object. * * @param jcas */ private void storeAnnotationVersion(JCas jcas) { FSIterator<TOP> itr = jcas.getJFSIndexRepository().getAllIndexedFS(Pairs.type); if (itr == null || !itr.hasNext()) return; Pairs props = (Pairs) itr.next(); // create a new property array that is one item bigger FSArray propArr = props.getPairs(); FSArray newPropArr = new FSArray(jcas, propArr.size() + 1); for (int i = 0; i < propArr.size(); i++) { newPropArr.set(i, propArr.get(i)); } Pair annotVerProp = new Pair(jcas); annotVerProp.setAttribute(iv_annotVerPropKey); annotVerProp.setValue(String.valueOf(iv_annotVer)); // add annotation version prop as last item in array newPropArr.set(newPropArr.size() - 1, annotVerProp); props.setPairs(newPropArr); } public void processCas(CAS cas) throws ResourceProcessException {