本文整理匯總了Java中org.apache.uima.cas.CAS.getView方法的典型用法代碼示例。如果您正苦於以下問題:Java CAS.getView方法的具體用法?Java CAS.getView怎麽用?Java CAS.getView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.uima.cas.CAS
的用法示例。
在下文中一共展示了CAS.getView方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: adaptFile
import org.apache.uima.cas.CAS; //導入方法依賴的package包/類
@Override
public void adaptFile(CAS cas, Path path) throws CollectionException {
LOGGER.info("Deserializing an input stream into a cas");
try (InputStream inputStream = Files.newInputStream(path)) {
XmiCasDeserializer.deserialize(inputStream, cas,
!(failOnUnknownType == null || failOnUnknownType));
} catch (SAXException | IOException e) {
LOGGER.error("Failed on document: {}", path);
throw new CollectionException(e);
}
if (addDocumentId != null && addDocumentId) {
CAS metadata = cas.getView("metadata");
Type idType = metadata.getTypeSystem()
.getType("edu.umn.biomedicus.uima.type1_5.DocumentId");
Feature idFeat = idType.getFeatureByBaseName("documentId");
FeatureStructure fs = metadata.createFS(idType);
fs.setStringValue(idFeat, path.getFileName().toString());
metadata.addFsToIndexes(fs);
}
}
示例2: CASDocument
import org.apache.uima.cas.CAS; //導入方法依賴的package包/類
CASDocument(@Nullable LabelAdapters labelAdapters, CAS cas) {
this.labelAdapters = labelAdapters;
this.cas = cas;
TypeSystem typeSystem = cas.getTypeSystem();
metadataType = typeSystem
.getType("edu.umn.biomedicus.uima.type1_5.DocumentMetadata");
keyFeature = metadataType.getFeatureByBaseName("key");
valueFeature = metadataType.getFeatureByBaseName("value");
metadata = cas.getView("metadata");
Type idType = typeSystem
.getType("edu.umn.biomedicus.uima.type1_5.DocumentId");
Feature idFeat = idType.getFeatureByBaseName("documentId");
documentId = metadata.getIndexRepository()
.getAllIndexedFS(idType)
.get()
.getStringValue(idFeat);
}
示例3: process
import org.apache.uima.cas.CAS; //導入方法依賴的package包/類
@Override
public void process(CAS aCAS) throws AnalysisEngineProcessException {
LOGGER.debug("Annotating rtf paragraphs.");
CAS systemView = aCAS.getView(Views.SYSTEM_VIEW);
Type newParagraphType = systemView.getTypeSystem()
.getType("edu.umn.biomedicus.rtfuima.type.NewParagraph");
Type paragraphType = systemView.getTypeSystem()
.getType("edu.umn.biomedicus.type.ParagraphAnnotation");
AnnotationIndex<AnnotationFS> newParagraphIndex = systemView
.getAnnotationIndex(newParagraphType);
int start = 0;
for (AnnotationFS newParagraph : newParagraphIndex) {
int end = newParagraph.getEnd();
systemView.addFsToIndexes(
systemView.createAnnotation(paragraphType, start, end));
start = end;
}
}
示例4: process
import org.apache.uima.cas.CAS; //導入方法依賴的package包/類
@Override
public void process(CAS aCAS) throws AnalysisEngineProcessException {
LOGGER.debug("Segmenting rtf text.");
CAS systemView = aCAS.getView("SystemView");
TextSegmentsBuilder textSegmentsBuilder = new TextSegmentsBuilder(systemView);
TypeSystem typeSystem = systemView.getTypeSystem();
textSegmentsBuilder.addAnnotations(typeSystem
.getType("edu.umn.biomedicus.type.ParagraphAnnotation"));
textSegmentsBuilder.addAnnotations(typeSystem
.getType("edu.umn.biomedicus.type.RowAnnotation"));
textSegmentsBuilder.addAnnotations(typeSystem
.getType("edu.umn.biomedicus.type.CellAnnotation"));
textSegmentsBuilder.addAnnotations(typeSystem
.getType("edu.umn.biomedicus.type.NestedRowAnnotation"));
textSegmentsBuilder.addAnnotations(typeSystem
.getType("edu.umn.biomedicus.type.NestedCellAnnotation"));
textSegmentsBuilder.buildInView();
}
示例5: parseFile
import org.apache.uima.cas.CAS; //導入方法依賴的package包/類
/**
* Parses the rtf source into a set of UIMA CAS views.
*
* @param cas parent jCas view to create destination views in.
* @param rtfSource the source rtf document.
* @throws IOException if there is a problem reading.
* @throws RtfReaderException if there is a problem parsing.
*/
void parseFile(CAS cas, RtfSource rtfSource)
throws IOException, RtfReaderException {
List<DestinationCasMapping> destinationCasMappings = casMappings
.getDestinationCasMappings();
Map<String, Type> annotationTypeForSymbolName = casMappings
.getControlWordCasMappings()
.stream()
.collect(Collectors.toMap(ControlWordCasMapping::getControlWord,
p -> cas.getTypeSystem()
.getType(p.getAnnotationName())));
OutputDestinationFactory outputDestinationFactory
= new CasOutputDestinationFactory(destinationCasMappings,
annotationTypeForSymbolName,
casMappings.getPropertyCasMappings(), cas);
CAS originalDocumentView = cas.getView(Views.ORIGINAL_DOCUMENT_VIEW);
IndexListener indexListener
= new CasIndexListener(originalDocumentView);
State initialState = State.createState(outputDestinationFactory,
initialProperties, indexListener);
RtfReader rtfReader = new RtfReader(rtfKeywordParser, rtfSource,
initialState);
rtfReader.parseFile();
}
示例6: process
import org.apache.uima.cas.CAS; //導入方法依賴的package包/類
@Override
public void process(CAS aCAS) throws AnalysisEngineProcessException {
Objects.requireNonNull(casRtfParser);
Objects.requireNonNull(originalDocumentViewName);
Objects.requireNonNull(targetViewName);
LOGGER.debug("Parsing an rtf document from {} into CAS", originalDocumentViewName);
CAS originalDocument = aCAS.getView(originalDocumentViewName);
String documentText = originalDocument.getDocumentText();
CAS targetView;
boolean isRtf;
if (documentText.indexOf("{\\rtf1") == 0) {
StringReader reader = new StringReader(documentText);
RtfSource rtfSource = new ReaderRtfSource(reader);
try {
casRtfParser.parseFile(aCAS, rtfSource);
} catch (IOException | RtfReaderException e) {
throw new AnalysisEngineProcessException(e);
}
isRtf = true;
} else {
targetView = aCAS.createView(targetViewName);
targetView.setDocumentText(documentText);
isRtf = false;
}
Document document = UimaAdapters.getDocument(aCAS, null);
document.putMetadata("isRtf", Boolean.toString(isRtf));
}
示例7: fromCAS
import org.apache.uima.cas.CAS; //導入方法依賴的package包/類
/**
* Creates a file name provider given the initial view of a jCas passed to a ae_writer
*
* @param cas any cas view
* @param extension extension to use, should include the separator e.g. ".".
* @return a newly initialized file name provider.
*/
public static String fromCAS(CAS cas, String extension) {
CAS metadata = cas.getView("metadata");
Type documentIdType = cas.getTypeSystem()
.getType("edu.umn.biomedicus.uima.type1_5.DocumentId");
Feature docIdFeat = documentIdType.getFeatureByBaseName("documentId");
return metadata.getIndexRepository()
.getAllIndexedFS(documentIdType)
.get()
.getStringValue(docIdFeat) + extension;
}
示例8: process
import org.apache.uima.cas.CAS; //導入方法依賴的package包/類
@Override
public void process(CAS aCAS) throws AnalysisEngineProcessException {
CAS originalDocumentView = aCAS.getView(Views.ORIGINAL_DOCUMENT_VIEW);
SymbolIndexedDocument symbolIndexedDocument
= SymbolIndexedDocument.fromView(originalDocumentView);
CAS view = aCAS.getView(Views.SYSTEM_VIEW);
TreeSet<Integer> covered = new TreeSet<>();
for (String annotationType : Objects.requireNonNull(annotationTypes)) {
Type type = view.getTypeSystem().getType(annotationType);
AnnotationIndex<Annotation> annotationIndex = view.getAnnotationIndex(type);
for (Annotation annotation : annotationIndex) {
IntStream.rangeClosed(annotation.getBegin(), annotation.getEnd()).forEach(covered::add);
}
}
Iterator<Integer> iterator = covered.iterator();
int next = iterator.next();
int last = -1;
while (iterator.hasNext()) {
int first = next;
while (iterator.hasNext()) {
last = next;
next = iterator.next();
if (next - last > 1) {
break;
}
}
RegionTaggerBuilder.create()
.withBeginTag("\\u2222221B ")
.withEndTag("\\u2222221E ")
.withSymbolIndexedDocument(symbolIndexedDocument)
.withDestinationName(Views.SYSTEM_VIEW)
.withBegin(first)
.withEnd(last)
.createRegionTagger()
.tagRegion();
}
String rewrittenDocument = symbolIndexedDocument.getDocument();
String fileName = FileNameProviders.fromCAS(view, ".rtf");
Path file = outputDir.resolve(fileName);
try (BufferedWriter bufferedWriter = Files
.newBufferedWriter(file, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE)) {
bufferedWriter.write(rewrittenDocument);
} catch (IOException e) {
throw new AnalysisEngineProcessException(e);
}
}