public static JCas getView(JCas jcas, Type type) throws CASException { String viewName = type.toString(); try { return jcas.getView(viewName); } catch (Exception e) { return null; } }
private Annotation getAnnotationObject(JCas aJCas, String viewName, String txpAnnotValue, Class<?> defaultClass) throws Exception{ if (AnnotMap.containsKey(txpAnnotValue)) { Class<?> txpAnnotClass = Class.forName(AnnotMap.get(txpAnnotValue)); Constructor<?> txpAnnotClassConstr = txpAnnotClass.getConstructor(JCas.class); return (Annotation) txpAnnotClassConstr.newInstance(aJCas.getView(viewName)); } Constructor<?> txpAnnotClassConstr = defaultClass.getConstructor(JCas.class); return (Annotation) txpAnnotClassConstr.newInstance(aJCas.getView(viewName)); }
@Override public JCas getView(String localViewName) throws CASException { testLiveness(); return delegate.getView(localViewName); }
@Override public JCas getView(SofaFS aSofa) throws CASException { testLiveness(); return delegate.getView(aSofa); }
private JCas getAnnotationView( final JCas jCas ) throws AnalysisEngineProcessException { if ( this.isTraining() ) { try { return jCas.getView( this.goldViewName ); } catch ( CASException e ) { throw new AnalysisEngineProcessException( e ); } } return jCas; }
/** * @return The view with name {@link #DEFAULT_VIEW} */ static public JCas getDefaultView( final JCas jCas ) { try { return jCas.getView( DEFAULT_VIEW ); } catch ( CASException casE ) { LOGGER.error( casE.getMessage() ); } return jCas; }
private JCas getAnnotationView( final JCas jCas ) throws AnalysisEngineProcessException { if ( this.isTraining() ) { try { return jCas.getView( this.goldViewName ); } catch ( CASException e ) { throw new AnalysisEngineProcessException( e ); } } return jCas; }
private static String[] lines(JCas jCas, String viewName) throws AnalysisEngineProcessException { JCas view; try { view = jCas.getView(viewName); } catch (CASException e) { throw new AnalysisEngineProcessException(e); } String text = view.getDocumentText(); if (text == null) { throw new IllegalArgumentException("no text in view " + viewName); } return text.length() > 0 ? text.split("\n") : new String[0]; }
private static String[] lines(JCas jCas, String viewName) throws AnalysisEngineProcessException { JCas view; try { view = jCas.getView(viewName); } catch (CASException e) { throw new AnalysisEngineProcessException(e); } String text = view.getDocumentText(); if (text == null) { throw new IllegalArgumentException("no text in view " + viewName); } return text.length() > 0 ? text.split("\n") : new String[0]; }
private void checkErrorConditionCasHasTwoVies(JCas jcas) throws AnalysisEngineProcessException { try { jcas.getView(Constants.PART_ONE); jcas.getView(Constants.PART_TWO); } catch (CASException e) { throw new AnalysisEngineProcessException(new TextClassificationException( "Your experiment is configured to be pair classification, but I could not find the two views " + Constants.PART_ONE + " and " + Constants.PART_TWO + ". Please use a reader that inhereits from " + Constants.class.getName())); } }
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { JCas srcView, tgtView; try { srcView = aJCas.getView(sourceViewName); tgtView = aJCas.getView(targetViewName); for (Annotation a : JCasUtil.select(srcView, clazz)) { AnnotationFactory.createAnnotation(tgtView, a.getBegin(), a.getEnd(), clazz); } } catch (CASException e) { throw new AnalysisEngineProcessException(e); } }
@Override public void process( JCas jCas ) throws AnalysisEngineProcessException { try { JCas goldView = jCas.getView( GOLD_VIEW_NAME ); goldView.setDocumentText( jCas.getDocumentText() ); } catch ( CASException e ) { throw new AnalysisEngineProcessException( e ); } } }
@SuppressWarnings("synthetic-access") @Override public void process(JCas jcas) throws AnalysisEngineProcessException { JCas goldView = null; try { goldView = jcas.getView(goldViewName); } catch (CASException e) { e.printStackTrace(); throw new AnalysisEngineProcessException(e); } copyRelations(jcas, goldView, dropout); }
private Annotation getAnnotationObject(JCas aJCas, String viewName, String type, Integer[] index) throws Exception{ if (type.matches(txpAnn.token)) return new Token(aJCas.getView(viewName)); if (type.matches(txpAnn.lemma)) return new Lemma(aJCas.getView(viewName)); if (type.matches(txpAnn.pos)) return getAnnotationObject(aJCas, viewName, txpAnn.getAnnotation(type).get(index), POS.class); if (type.matches(txpAnn.sentence)) return new Sentence(aJCas.getView(viewName)); if (type.matches(txpAnn.ne)) return getAnnotationObject(aJCas, viewName, txpAnn.getNEtype(index), NamedEntity.class); return new Annotation(aJCas.getView(viewName)); }
@Override public void process( JCas jCas ) throws AnalysisEngineProcessException { try { JCas goldView = jCas.getView( GOLD_VIEW_NAME ); goldView.setDocumentText( jCas.getDocumentText() ); } catch ( CASException e ) { throw new AnalysisEngineProcessException( e ); } } }
public static String getDocId(JCas jcas) { String docId = null; docId = DocumentIDAnnotationUtil.getDocumentID(jcas); if(docId != DocumentIDAnnotationUtil.NO_DOCUMENT_ID) return docId; try{ if(jcas.getView(ViewUriUtil.URI) != null){ docId = ViewUriUtil.getURI(jcas).toString(); } }catch(Exception e){ // don't need to do anything -- just return null } return docId; }
public static JCas getAlignedGoldCas(final JCas patientJCas, final JCas docView) throws CASException { String pid = PatientNoteStore.getDefaultPatientId( patientJCas ); String docId = PatientNoteStore.getDefaultDocumentId( docView ).replace(CAS.NAME_DEFAULT_SOFA, ""); String goldViewName = PatientNoteStore.getInternalViewname( pid, docId, GOLD_PREFIX ); return patientJCas.getView(goldViewName); }
public static JCas getAlignedDocCas(final JCas patientJCas, final JCas goldView) throws CASException { String pid = PatientNoteStore.getDefaultPatientId( patientJCas ); String docId = PatientNoteStore.getDefaultDocumentId( goldView ).replace("GoldView_", ""); String docViewName = PatientNoteStore.getInternalViewname( pid, docId, CAS.NAME_DEFAULT_SOFA ); return patientJCas.getView(docViewName); } }
@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { try { JCas sourceView = aJCas.getView(VIEW_SOURCE); JCas targetView = aJCas.createView(VIEW_TARGET); DocumentMetaData.copy(sourceView, targetView); applyChanges(sourceView, targetView); } catch (CASException e) { throw new AnalysisEngineProcessException(e); } }