/** * Set the primary Uniform Resource Identifier for this CAS and all its views. This creates the * view {@link #URI} and assigns the URI there. * * @param cas * The CAS object. * @param uri * The primary URI for the CAS and all its views. */ public static void setURI(CAS cas, java.net.URI uri) { CAS view = cas.createView(URI); view.setSofaDataURI(uri.toString(), null); }
/** * Set the primary Uniform Resource Identifier for this CAS and all its views. This creates the * view {@link #URI} and assigns the URI there. * * @param cas * The CAS object. * @param uri * The primary URI for the CAS and all its views. */ public static void setURI(CAS cas, java.net.URI uri) { CAS view = cas.createView(URI); view.setSofaDataURI(uri.toString(), null); }
/** * Gets the named view; if the view doesn't exist it will be created. */ private static CAS getOrCreateView(CAS aCas, String aViewName) { // TODO: there should be some way to do this without the try...catch try { return aCas.getView(aViewName); } catch (CASRuntimeException e) { // create the view return aCas.createView(aViewName); } }
@Nonnull @Override public Document addDocument(@Nonnull String name, @Nonnull String text) { CAS view = cas.createView(name); view.setDocumentText(text); return new CASDocument(view, labelAdapters); }
/** * Convenience method to get the specified view or create a new view if the requested view does * not exist. * * @param cas * a CAS * @param viewName * the requested view. * @param create * the view is created if it does not exist. * @return the requested view * @throws IllegalArgumentException * if the view does not exist and is not to be created. */ public static CAS getView(CAS cas, String viewName, boolean create) { CAS view; try { view = cas.getView(viewName); } catch (CASRuntimeException e) { // View does not exist if (create) { view = cas.createView(viewName); } else { throw new IllegalArgumentException("No view with name [" + viewName + "]"); } } return view; }
/** * Gets the named view; if the view doesn't exist it will be created. */ private static CASImpl getOrCreateView(CAS aCas, String aViewName) { //TODO: there should be some way to do this without the try...catch try { // throws if view doesn't exist return (CASImpl) aCas.getView(aViewName).getLowLevelCAS(); } catch(CASRuntimeException e) { //create the view return (CASImpl) aCas.createView(aViewName).getLowLevelCAS(); } }
@Override public OutputDestination create(String destinationName) { DestinationCasMapping matchingCasMapping = null; for (DestinationCasMapping destMapping : destinationCasMappings) { if (destinationName.equals(destMapping.getDestinationName())) { matchingCasMapping = destMapping; } } if (matchingCasMapping == null) { return new IgnoreOutputDestination(destinationName); } CAS newView = cas.createView(matchingCasMapping.getViewName()); return new CasOutputDestination( newView, propertyCasMappings, annotationTypeForSymbolName, destinationName, writeTables ); } }
targetView = aCAS.createView(targetViewName); targetView.setDocumentText(documentText); isRtf = false;
cas = cas.createView(view);
public void process(CAS aCAS) throws AnalysisEngineProcessException { // get handle to CAS view containing XML document CAS xmlCas = aCAS.getView("xmlDocument"); InputStream xmlStream = xmlCas.getSofa().getSofaDataStream(); // parse with detag handler DetagHandler handler = new DetagHandler(); try { SAXParser parser = parserFactory.newSAXParser(); parser.parse(xmlStream, handler); } catch (Exception e) { throw new AnalysisEngineProcessException(e); } // create the plain text view and set its document text CAS plainTextView = aCAS.createView("plainTextDocument"); plainTextView.setDocumentText(handler.getDetaggedText()); plainTextView.setDocumentLanguage(aCAS.getView("_InitialView").getDocumentLanguage()); // Index the SourceDocumentInformation object, if there is one, in the new sofa. // This is needed by the SemanticSearchCasIndexer Iterator iter = xmlCas.getAnnotationIndex(sourceDocInfoType).iterator(); if (iter.hasNext()) { FeatureStructure sourceDocInfoFs = (FeatureStructure) iter.next(); plainTextView.getIndexRepository().addFS(sourceDocInfoFs); } }
casList[i].createView(CAS.NAME_DEFAULT_SOFA);
CASArtifact( @Nullable LabelAdapters labelAdapters, CAS cas, String artifactID ) { this.labelAdapters = labelAdapters; this.cas = cas; TypeSystem typeSystem = cas.getTypeSystem(); metadataType = typeSystem.getType("ArtifactMetadata"); keyFeature = metadataType.getFeatureByBaseName("key"); valueFeature = metadataType.getFeatureByBaseName("value"); metadataCas = cas.createView("metadata"); metadataCas.setDocumentText(""); Type idType = typeSystem.getType("ArtifactID"); Feature idFeat = idType.getFeatureByBaseName("artifactID"); this.artifactID = artifactID; FeatureStructure documentIdFs = metadataCas.createFS(idType); documentIdFs.setStringValue(idFeat, artifactID); metadataCas.addFsToIndexes(documentIdFs); metadataIndex = metadataCas.getIndexRepository().getIndex("metadata", metadataType); casMetadata = new CASMetadata(); }
toView = newCas; } else { toView = newCas.createView(toViewName);
CASArtifact( @Nullable LabelAdapters labelAdapters, Artifact artifact, CAS cas ) { this.labelAdapters = labelAdapters; this.cas = cas; TypeSystem typeSystem = cas.getTypeSystem(); metadataType = typeSystem.getType("ArtifactMetadata"); keyFeature = metadataType.getFeatureByBaseName("key"); valueFeature = metadataType.getFeatureByBaseName("value"); metadataCas = cas.createView("metadata"); metadataCas.setDocumentText(""); Type idType = typeSystem.getType("ArtifactID"); Feature idFeat = idType.getFeatureByBaseName("artifactID"); this.artifactID = artifact.getArtifactID(); FeatureStructure documentIdFs = metadataCas.createFS(idType); documentIdFs.setStringValue(idFeat, artifactID); metadataCas.addFsToIndexes(documentIdFs); metadataIndex = metadataCas.getIndexRepository().getIndex("metadata", metadataType); casMetadata = new CASMetadata(); casMetadata.putAll(artifact.getMetadata()); copyDocuments(artifact); }