org.apache.uima.cas.CAS.createView()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(88)

本文整理了Java中org.apache.uima.cas.CAS.createView()方法的一些代码示例,展示了CAS.createView()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CAS.createView()方法的具体详情如下:
包路径:org.apache.uima.cas.CAS
类名称:CAS
方法名:createView

CAS.createView介绍

[英]Create a view and its underlying Sofa (subject of analysis). The view provides access to the Sofa data and the index repository that contains metadata (annotations and other feature structures) pertaining to that Sofa.

This method creates the underlying Sofa feature structure, but does not set the Sofa data. Setting ths Sofa data must be done by calling #setSofaDataArray(FeatureStructure,String), #setSofaDataString(String,String) or #setSofaDataURI(String,String) on the CAS view returned by this method.
[中]创建视图及其底层沙发(分析主题)。该视图提供对Sofa数据和包含与该Sofa相关的元数据(注释和其他要素结构)的索引存储库的访问。
此方法创建基础Sofa要素结构,但不设置Sofa数据。必须通过调用此方法返回的CAS视图上的#setSofaDataArray(FeatureStructure,String)、#setSofaDataString(String,String)或#setSofaDataURI(String,String)来设置Sofa数据。

代码示例

代码示例来源:origin: org.cleartk/cleartk-util

/**
 * 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);
}

代码示例来源:origin: ClearTK/cleartk

/**
 * 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);
}

代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.stanfordnlp-gpl

/**
 * 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);
  }
}

代码示例来源:origin: nlpie/biomedicus

@Nonnull
@Override
public Document addDocument(@Nonnull String name, @Nonnull String text) {
 CAS view = cas.createView(name);
 view.setDocumentText(text);
 return new CASDocument(view, labelAdapters);
}

代码示例来源:origin: org.apache.uima/uimafit-core

/**
 * 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;
}

代码示例来源:origin: apache/uima-uimaj

/**
 * 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(); 
 }
}

代码示例来源:origin: nlpie/biomedicus

@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
  );
 }
}

代码示例来源:origin: nlpie/biomedicus

targetView = aCAS.createView(targetViewName);
targetView.setDocumentText(documentText);
isRtf = false;

代码示例来源:origin: org.apache.uima/ruta-ep-ide-ui

cas = cas.createView(view);

代码示例来源:origin: org.apache.uima/uimaj-tools

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);
 }
}

代码示例来源:origin: org.apache.uima/uimaj-cpe

casList[i].createView(CAS.NAME_DEFAULT_SOFA);

代码示例来源:origin: nlpie/biomedicus

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();
}

代码示例来源:origin: nlpie/biomedicus

toView = newCas;
} else {
 toView = newCas.createView(toViewName);

代码示例来源:origin: nlpie/biomedicus

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);
}

相关文章