public int compare( final JCas jCas1, final JCas jCas2 ) { return __delegate.compare( jCas1.getViewName(), jCas2.getViewName() ); } }
private static JCas getAlignedDocCas(Collection<JCas> docCases, JCas goldCas) { JCas docCas = null; for (JCas candidate : docCases) { if (goldCas.getViewName().replace(GOLD_VIEW_NAME, CAS.NAME_DEFAULT_SOFA).equals(candidate.getViewName())) { docCas = candidate; break; } } return docCas; } }
@Override public int compare(JCas cas0, JCas cas1) { String v0 = cas0.getViewName(); String v1 = cas1.getViewName(); Matcher m = fnPatt.matcher(v0); int doc0Id = -1, doc1Id = -1; if(m.find()){ doc0Id = Integer.parseInt(m.group(3)); } m = fnPatt.matcher(v1); if(m.find()){ doc1Id = Integer.parseInt(m.group(3)); } return doc0Id - doc1Id; } }
public static List<JCas> getOrderedCases(JCas jCas) { List<JCas> cases = new ArrayList<>(); Collection<JCas> allViews = PatientViewUtil.getAllViews(jCas); for(JCas jcas : allViews){ // contains the default CAS name but isn't _exactly_ the default CAS name (that would be the main patient cas) if(jcas.getViewName().contains(CAS.NAME_DEFAULT_SOFA) && jcas.getViewName().length() > CAS.NAME_DEFAULT_SOFA.length()){ cases.add(jcas); } } // TODO: Resort this based on last item of name (e.g. ID001_clinic_003 use 003 as its index) Collections.sort(cases, sorter); return cases; }
@Override public String getViewName() { testLiveness(); return delegate.getViewName(); }
/** * helper to look for plain text view for CDA processing or else use the default view. * @param cas * @param name * @return * @throws CASException */ public static JCas getJCasViewWithDefault(CAS cas, String name) throws CASException{ JCas returnCas = null; Iterator<JCas> viewItr = cas.getJCas().getViewIterator(); while(viewItr.hasNext()){ JCas newJcas = viewItr.next(); if(newJcas.getViewName().equals(name)){ returnCas = newJcas; } } if (returnCas == null) returnCas = cas.getJCas(); return returnCas; } }
/** * helper to look for plain text view for CDA processing or else use the default view. * @param cas * @param name * @return * @throws CASException */ public static JCas getJCasViewWithDefault(CAS cas, String name) throws CASException{ JCas returnCas = null; Iterator<JCas> viewItr = cas.getJCas().getViewIterator(); while(viewItr.hasNext()){ JCas newJcas = viewItr.next(); if(newJcas.getViewName().equals(name)){ returnCas = newJcas; } } if (returnCas == null) returnCas = cas.getJCas(); return returnCas; } }
@Override public void process(JCas docCas) throws AnalysisEngineProcessException { try { for (Iterator<JCas> it = docCas.getViewIterator(); it.hasNext(); ) { JCas jCas = it.next(); String uri = new File(ViewUriUtil.getURI(jCas)).getName(); // if some default DocumentID was added earlier, delete it: Collection<DocumentID> oldDocIDs = JCasUtil.select(jCas, DocumentID.class); for(DocumentID oldDocID : oldDocIDs) { oldDocID.removeFromIndexes(); } DocumentID docId = new DocumentID(jCas); if(jCas.getViewName().equals(GOLD_VIEW_NAME)){ docId.setDocumentID(GOLD_VIEW_NAME + "_" + uri); }else if(jCas.getViewName().equals(CAS.NAME_DEFAULT_SOFA)){ docId.setDocumentID(uri); }else{ docId.setDocumentID(jCas.getViewName() + "_" + uri); } docId.addToIndexes(); DocumentIdPrefix docPrefix = new DocumentIdPrefix(jCas); docPrefix.setDocumentIdPrefix(uri.split("_")[0]); docPrefix.addToIndexes(); } }catch(CASException e){ throw new AnalysisEngineProcessException(e); } } }
JCas view = viewIterator.next(); String viewName = view.getViewName(); if (sourceViewName.equals(viewName)) { JCas targetView;
if (docView.getViewName().equals(CAS.NAME_DEFAULT_SOFA) || !docView.getViewName().contains("Initial")) { continue; System.out.print("Mention: " + member.getCoveredText().replace("\n", "<CR>")); sysEntChainMap.put(member, sysChainNum); if(!member.getView().getViewName().equals(docView.getViewName())){ System.out.print("[DOC:" + member.getView().getViewName() + "]");
LOGGER.debug("Copied " + countCopied + " gold annotations out of " + (countSkipped+countCopied) + " to cas, which now has " + newGoldView.getAnnotationIndex().size() + " indexed annotations in " +newGoldView.getViewName()); LOGGER.debug(" and has " + jCas.getAnnotationIndex().size() + " indexed annotations in " +jCas.getViewName());
LOGGER.debug("Copied " + countCopied + " gold annotations out of " + (countSkipped+countCopied) + " to cas, which now has " + newGoldView.getAnnotationIndex().size() + " indexed annotations in " +newGoldView.getViewName()); LOGGER.debug(" and has " + jCas.getAnnotationIndex().size() + " indexed annotations in " +jCas.getViewName());
protected void applyChanges(JCas aSourceView, JCas aTargetView) { AlignedString as = AlignmentFactory.createAlignmentsFor(aSourceView); // Set the text of the new Sofa aTargetView.setDocumentText(as.get()); // Set document language aTargetView.setDocumentLanguage(aSourceView.getDocumentLanguage()); // Optionally we may want to remember the AlignedString for the backmapper. AlignmentStorage.getInstance().put(aSourceView.getCasImpl().getBaseCAS(), aSourceView.getViewName(), aTargetView.getViewName(), as); } }
private static JCas getViewWithGoldAnnotations(JCas correspondingCasThatHasGoldAnnotations) { JCas viewWithPreexistingGoldAnnotations = null; try { viewWithPreexistingGoldAnnotations = correspondingCasThatHasGoldAnnotations.getView(AssertionEvaluation.GOLD_VIEW_NAME); } catch (org.apache.uima.cas.CASRuntimeException cre) { // Let it just continue if there's an exception and check for null later } catch (org.apache.uima.cas.CASException viewException) { // Let it just continue if there's an exception and check for null later } catch (NullPointerException npe) { // Let it just continue if there's an exception and check for null later } if (viewWithPreexistingGoldAnnotations == null) { viewWithPreexistingGoldAnnotations = correspondingCasThatHasGoldAnnotations; LOGGER.debug("Using view " + viewWithPreexistingGoldAnnotations.getViewName()); int n = viewWithPreexistingGoldAnnotations.getAnnotationIndex().size(); LOGGER.debug("With " + n + " annotations"); if (n==0) { Iterator<CAS> iter = viewWithPreexistingGoldAnnotations.getCas().getViewIterator(); while (iter.hasNext()) { CAS cas = iter.next(); LOGGER.debug("view " + cas.getViewName() + " has " + cas.getAnnotationIndex().size() + " indexed annotations."); } throw new RuntimeException("n==0"); } } return viewWithPreexistingGoldAnnotations; }
private static JCas getViewWithGoldAnnotations(JCas correspondingCasThatHasGoldAnnotations) { JCas viewWithPreexistingGoldAnnotations = null; try { viewWithPreexistingGoldAnnotations = correspondingCasThatHasGoldAnnotations.getView(AssertionEvaluation.GOLD_VIEW_NAME); } catch (org.apache.uima.cas.CASRuntimeException cre) { // Let it just continue if there's an exception and check for null later } catch (org.apache.uima.cas.CASException viewException) { // Let it just continue if there's an exception and check for null later } catch (NullPointerException npe) { // Let it just continue if there's an exception and check for null later } if (viewWithPreexistingGoldAnnotations == null) { viewWithPreexistingGoldAnnotations = correspondingCasThatHasGoldAnnotations; LOGGER.debug("Using view " + viewWithPreexistingGoldAnnotations.getViewName()); int n = viewWithPreexistingGoldAnnotations.getAnnotationIndex().size(); LOGGER.debug("With " + n + " annotations"); if (n==0) { Iterator<CAS> iter = viewWithPreexistingGoldAnnotations.getCas().getViewIterator(); while (iter.hasNext()) { CAS cas = iter.next(); LOGGER.debug("view " + cas.getViewName() + " has " + cas.getAnnotationIndex().size() + " indexed annotations."); } throw new RuntimeException("n==0"); } } return viewWithPreexistingGoldAnnotations; }
LOGGER.info("Processing document with view name: " + view.getViewName()); processDocument( view, prevView, relationLookup ); prevView = view;
@Override public void process(JCas cas) throws AnalysisEngineProcessException { try { String viewName = cas.getViewName(); if (viewName == null) { cas = cas.getView(CAS.NAME_DEFAULT_SOFA); while (viewIterator.hasNext()) { JCas each = (JCas) viewIterator.next(); if (each.getViewName().equals(modifiedViewName)) { modifiedView = each; break;
/** * Invokes this annotator's analysis logic. Invoked for each document * processed. */ public void process(JCas jcas) throws AnalysisEngineProcessException { String text = jcas.getDocumentText(); try { // just one sentence iv_logger.info(" jcas "+ jcas.getViewName()); if (!useSegments) { // annotate over full doc text annotateRange(jcas, text, 0, text.length()); } else { JFSIndexRepository indexes = jcas.getJFSIndexRepository(); Iterator<?> segmentItr = indexes.getAnnotationIndex( Segment.type).iterator(); while (segmentItr.hasNext()) { Segment segmentAnnotation = (Segment) segmentItr.next(); String segmentID = segmentAnnotation.getId(); if (!skipSegmentsSet.contains(segmentID)) { int start = segmentAnnotation.getBegin(); int end = segmentAnnotation.getEnd(); annotateRange(jcas, text, start, end); } } } } catch (AnnotatorContextException e) { e.printStackTrace(); } }
@Override public void process(JCas cas) throws AnalysisEngineProcessException { try { String viewName = cas.getViewName(); if (viewName == null) { cas = cas.getView(CAS.NAME_DEFAULT_SOFA); while (viewIterator.hasNext()) { JCas each = (JCas) viewIterator.next(); if (each.getViewName().equals(modifiedViewName)) { modifiedView = each; break;
/** * Invokes this annotator's analysis logic. Invoked for each document * processed. */ public void process(JCas jcas) throws AnalysisEngineProcessException { String text = jcas.getDocumentText(); try { // just one sentence iv_logger.info(" jcas "+ jcas.getViewName()); if (!useSegments) { // annotate over full doc text annotateRange(jcas, text, 0, text.length()); } else { JFSIndexRepository indexes = jcas.getJFSIndexRepository(); Iterator<?> segmentItr = indexes.getAnnotationIndex( Segment.type).iterator(); while (segmentItr.hasNext()) { Segment segmentAnnotation = (Segment) segmentItr.next(); String segmentID = segmentAnnotation.getId(); if (!skipSegmentsSet.contains(segmentID)) { int start = segmentAnnotation.getBegin(); int end = segmentAnnotation.getEnd(); annotateRange(jcas, text, start, end); } } } } catch (AnnotatorContextException e) { e.printStackTrace(); } }