private void processDocumentMetadata(CAS aCAS) { if (!writeDocumentMetaData) { return; } processFeatureStructure(aCAS.getDocumentAnnotation()); }
private void processDocumentMetadata(CAS aCAS) { if (!writeDocumentMetaData) { return; } processFeatureStructure(aCAS.getDocumentAnnotation()); }
private void processDocumentMetadata(CAS aCAS) { if (!writeDocumentMetaData) { return; } processFeatureStructure(aCAS.getDocumentAnnotation()); }
/** * Determines whether the given FS is the DocumentAnnotation for its view. This is more than * just a type check; we actually check if it is the one "special" DocumentAnnotation that * CAS.getDocumentAnnotation() would return. */ private static boolean isDocumentAnnotation(FeatureStructure aFS) { return (aFS instanceof AnnotationFS) && aFS.equals(((AnnotationFS) aFS).getView().getDocumentAnnotation()); }
private Set<String> getTypes(CAS cas) { Set<String> types = new HashSet<String>(); Iterator<Type> typeIt = cas.getTypeSystem().getTypeIterator(); nextType: while (typeIt.hasNext()) { Type type = typeIt.next(); if (type.getName().equals(cas.getDocumentAnnotation().getType().getName())) { continue; } for (InExPattern p : cookedTypePatterns) { p.matchter.reset(type.getName()); if (p.matchter.matches()) { if (p.includeInOutput) { types.add(type.getName()); } else { types.remove(type.getName()); } continue nextType; } } } return types; }
private Set<String> getTypes(CAS cas) { Set<String> types = new HashSet<String>(); Iterator<Type> typeIt = cas.getTypeSystem().getTypeIterator(); nextType: while (typeIt.hasNext()) { Type type = typeIt.next(); if (type.getName().equals(cas.getDocumentAnnotation().getType().getName())) { continue; } for (InExPattern p : cookedTypePatterns) { p.matchter.reset(type.getName()); if (p.matchter.matches()) { if (p.includeInOutput) { types.add(type.getName()); } else { types.remove(type.getName()); } continue nextType; } } } return types; }
private Set<String> getTypes(CAS cas) { Set<String> types = new HashSet<String>(); Iterator<Type> typeIt = cas.getTypeSystem().getTypeIterator(); nextType: while (typeIt.hasNext()) { Type type = typeIt.next(); if (type.getName().equals(cas.getDocumentAnnotation().getType().getName())) { continue; } for (InExPattern p : cookedTypePatterns) { p.matchter.reset(type.getName()); if (p.matchter.matches()) { if (p.includeInOutput) { types.add(type.getName()); } else { types.remove(type.getName()); } continue nextType; } } } return types; }
public static void addSourceDocumentInformation(CAS cas, File each) { Type sdiType = cas.getTypeSystem() .getType("org.apache.uima.examples.SourceDocumentInformation"); if (sdiType != null) { if (cas.getAnnotationIndex(sdiType).size() == 0) { AnnotationFS sdi = cas.createAnnotation(sdiType, cas.getDocumentAnnotation().getBegin(), cas.getDocumentAnnotation().getEnd()); Feature uriFeature = sdiType.getFeatureByBaseName("uri"); sdi.setStringValue(uriFeature, each.toURI().getPath()); cas.addFsToIndexes(sdi); } } }
public static void addSourceDocumentInformation(CAS cas, File each) { Type sdiType = cas.getTypeSystem() .getType("org.apache.uima.examples.SourceDocumentInformation"); if (sdiType != null) { if (cas.getAnnotationIndex(sdiType).size() == 0) { AnnotationFS sdi = cas.createAnnotation(sdiType, cas.getDocumentAnnotation().getBegin(), cas.getDocumentAnnotation().getEnd()); Feature uriFeature = sdiType.getFeatureByBaseName("uri"); sdi.setStringValue(uriFeature, each.toURI().getPath()); cas.addFsToIndexes(sdi); } } }
@Override public ScriptApply apply(RutaStream stream, InferenceCrowd crowd) { CAS cas = stream.getCas(); AnnotationFS documentAnnotation = cas.getDocumentAnnotation(); RutaStream completeStream = stream.getWindowStream(documentAnnotation, documentAnnotation.getType()); ScriptApply result = super.apply(completeStream, crowd); return result; }
protected RutaStream(CAS cas, Type basicType, NavigableMap<Integer, RutaBasic> beginAnchors, NavigableMap<Integer, RutaBasic> endAnchors, FilterManager filter, boolean lowMemoryProfile, boolean simpleGreedyForComposed, boolean emptyIsInvisible, TypeUsageInformation typeUsage, InferenceCrowd crowd) { super(); this.cas = cas; this.beginAnchors = beginAnchors; this.endAnchors = endAnchors; this.filter = filter; this.basicType = basicType; this.lowMemoryProfile = lowMemoryProfile; this.simpleGreedyForComposed = simpleGreedyForComposed; this.emptyIsInvisible = emptyIsInvisible; this.typeUsage = typeUsage; this.crowd = crowd; AnnotationFS additionalWindow = filter.getWindowAnnotation(); updateIterators(cas, basicType, filter, additionalWindow); // really an if? sub it of basic should fix this if (additionalWindow == null) { documentAnnotation = cas.getDocumentAnnotation(); documentAnnotationType = getCas().getDocumentAnnotation().getType(); basicIt.moveToFirst(); } else { documentAnnotation = additionalWindow; documentAnnotationType = filter.getWindowType(); } }
public Collection<RutaBasic> getAllBasicsInWindow(AnnotationFS windowAnnotation) { if (windowAnnotation.getBegin() >= windowAnnotation.getEnd()) { return Collections.emptySet(); } RutaBasic beginAnchor = getBeginAnchor(windowAnnotation.getBegin()); if (beginAnchor != null && beginAnchor.getEnd() == windowAnnotation.getEnd()) { Collection<RutaBasic> result = new ArrayList<RutaBasic>(1); result.add(beginAnchor); return result; } Collection<RutaBasic> subSet = null; if (windowAnnotation.getEnd() == cas.getDocumentAnnotation().getEnd() && windowAnnotation.getBegin() == 0) { subSet = beginAnchors.values(); } else { subSet = beginAnchors .subMap(windowAnnotation.getBegin(), true, windowAnnotation.getEnd(), false).values(); } return subSet; }
/** * Gets the feature as int. * * @param aCas the a cas * @param aFeature the a feature * @param aName the a name * @return the feature as int * @throws Exception the exception */ public static int getFeatureAsInt(CAS aCas, Feature aFeature, String aName) throws Exception { Feature seqNo2 = aFeature.getRange().getFeatureByBaseName(aName); FeatureStructure documentMetaData = aCas.getView(CAS.NAME_DEFAULT_SOFA).getDocumentAnnotation() .getFeatureValue(aFeature); return documentMetaData.getIntValue(seqNo2); }
AnnotationFS documentAnnotation = stream.getCas().getDocumentAnnotation(); Type docType = documentAnnotation.getType(); if (docType.equals(type)) {
return Collections.emptyList(); Type overallDAType = stream.getCas().getDocumentAnnotation().getType(); String name = type.getName(); if (StringUtils.equals(CAS.TYPE_NAME_DOCUMENT_ANNOTATION, name)
/** * Returns a value associated with a given feature. * * @param aCas - * Cas containing data to extract * @param aFeature - * feature to locate in the CAS * @param aName - * name of the feature * @return - value as String * @throws Exception the exception */ public static String getFeatureAsString(CAS aCas, Feature aFeature, String aName) throws Exception { Feature seqNo2 = aFeature.getRange().getFeatureByBaseName(aName); FeatureStructure documentMetaData = aCas.getView(CAS.NAME_DEFAULT_SOFA).getDocumentAnnotation() .getFeatureValue(aFeature); return documentMetaData.getStringValue(seqNo2); }
public Collection<AnnotationFS> getAnnotations(Type type) { Collection<AnnotationFS> result = new LinkedList<AnnotationFS>(); AnnotationFS windowAnnotation = filter.getWindowAnnotation(); if (windowAnnotation != null && (windowAnnotation.getBegin() != cas.getDocumentAnnotation().getBegin() || windowAnnotation.getEnd() != cas.getDocumentAnnotation().getEnd())) { AnnotationFS frame = cas.createAnnotation(cas.getTypeSystem().getType(RutaEngine.FRAME_TYPE), windowAnnotation.getBegin(), windowAnnotation.getEnd()); FSIterator<AnnotationFS> subiterator = cas.getAnnotationIndex(type).subiterator(frame); while (subiterator.hasNext()) { AnnotationFS each = subiterator.next(); if (isVisible(each)) { result.add(each); } } } else { AnnotationIndex<AnnotationFS> annotationIndex = cas.getAnnotationIndex(type); for (AnnotationFS each : annotationIndex) { if (isVisible(each)) { result.add(each); } } } return result; }
public AnnotationFS getVeryFirstBeforeWindow(boolean direction) { if (direction) { RutaBasic firstBasicOfAll = getFirstBasicOfAll(); int begin = firstBasicOfAll.getBegin(); if (begin == 0) { return documentBeginAnchor; } else { return getEndAnchor(begin); } } else { RutaBasic lastBasicOfAll = getLastBasicOfAll(); int end = lastBasicOfAll.getEnd(); if (end == cas.getDocumentAnnotation().getEnd()) { return documentEndAnchor; } else { return getBeginAnchor(end); } } }
public RutaStream(CAS cas, Type basicType, FilterManager filter, boolean lowMemoryProfile, boolean simpleGreedyForComposed, boolean emptyIsInvisible, TypeUsageInformation typeUsage, InferenceCrowd crowd) { super(); this.cas = cas; this.filter = filter; this.basicType = basicType; this.lowMemoryProfile = lowMemoryProfile; this.simpleGreedyForComposed = simpleGreedyForComposed; this.emptyIsInvisible = emptyIsInvisible; this.typeUsage = typeUsage; this.crowd = crowd; AnnotationFS additionalWindow = filter.getWindowAnnotation(); updateIterators(cas, basicType, filter, additionalWindow); // really an if? sub it of basic should fix this if (additionalWindow == null) { documentAnnotation = cas.getDocumentAnnotation(); documentAnnotationType = getCas().getDocumentAnnotation().getType(); basicIt.moveToFirst(); documentBeginAnchor = new RutaOptional(getJCas(), 0, 0); documentEndAnchor = new RutaOptional(getJCas(), documentAnnotation.getEnd(), documentAnnotation.getEnd()); } else { documentAnnotation = additionalWindow; documentAnnotationType = filter.getWindowType(); } }
final int mappedEnd = map[clone.getEnd()]; if (mappedBegin < mappedEnd) { if (mappedEnd > fromJcas.getCas().getDocumentAnnotation().getEnd()) { getContext().getLogger().log(Level.WARNING, "illegal annotation offset mapping"); } else { int max = modview.getCas().getDocumentAnnotation().getEnd(); if (mappedBegin < max && mappedEnd <= max && mappedBegin >= 0 && mappedEnd > 0) { clone.setBegin(mappedBegin);