本文整理汇总了Java中org.apache.uima.cas.Type.getFeatureByBaseName方法的典型用法代码示例。如果您正苦于以下问题:Java Type.getFeatureByBaseName方法的具体用法?Java Type.getFeatureByBaseName怎么用?Java Type.getFeatureByBaseName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.uima.cas.Type
的用法示例。
在下文中一共展示了Type.getFeatureByBaseName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: adaptFile
import org.apache.uima.cas.Type; //导入方法依赖的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: process
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
@Override
public void process(CAS aCAS) throws AnalysisEngineProcessException {
Type documentIdType = aCAS.getTypeSystem()
.getType("edu.umn.biomedicus.uima.type1_5.DocumentId");
Feature docIdFeat = documentIdType.getFeatureByBaseName("documentId");
String documentId = aCAS.getIndexRepository()
.getAllIndexedFS(documentIdType)
.get()
.getStringValue(docIdFeat);
if (documentId == null) {
documentId = UUID.randomUUID().toString();
}
GridFSInputFile file = gridFS.createFile(documentId + ".xmi");
try (OutputStream outputStream = file.getOutputStream()) {
XmiCasSerializer.serialize(aCAS, outputStream);
} catch (IOException | SAXException e) {
throw new AnalysisEngineProcessException(e);
}
}
示例3: CASDocument
import org.apache.uima.cas.Type; //导入方法依赖的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);
}
示例4: getAnnotation
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
@Nullable
AnnotationFS getAnnotation(CAS cas, int begin, int end, int value) {
if (begin < 0) {
throw new IllegalArgumentException("Begin: " + begin + "before 0.");
}
if (end < begin) {
throw new IllegalArgumentException(
annotationClassName + " - illegal annotation span at begin: " + begin
+ " end: " + end);
}
if (!zeroLengthEmitted && end == begin) {
return null;
}
TypeSystem typeSystem = cas.getTypeSystem();
Type type = typeSystem.getType(annotationClassName);
AnnotationFS annotation = cas.createAnnotation(type, begin, end);
if (valueIncluded) {
Feature valueFeature = type.getFeatureByBaseName("value");
annotation.setIntValue(valueFeature, value);
}
return annotation;
}
示例5: controlWordEncountered
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
@Override
public void controlWordEncountered(KeywordAction keywordAction) {
AnnotationFS annotation;
int currentTextIndex = sofaBuilder.length();
String controlWord = keywordAction.getControlWord();
Type type;
if (annotationTypeForControlWord.containsKey(controlWord)) {
type = annotationTypeForControlWord.get(controlWord);
} else {
return;
}
annotation = destinationView.createAnnotation(type, currentTextIndex,
currentTextIndex);
Feature paramFeature = type.getFeatureByBaseName("param");
if (keywordAction.hasParameter()) {
annotation.setIntValue(paramFeature, keywordAction.getParameter());
}
Feature indexFeature = type.getFeatureByBaseName("index");
annotation.setIntValue(indexFeature, keywordAction.getBegin());
Feature knownFeature = type.getFeatureByBaseName("known");
annotation.setBooleanValue(knownFeature, true);
destinationView.addFsToIndexes(annotation);
}
示例6: makeAnnotation
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
@Override
public void makeAnnotation(AnnotationFS firstToken, AnnotationFS lastToken, String tag) {
Preconditions.checkArgument(firstToken != null, "firstToken == null");
CAS cas = firstToken.getCAS();
Type targetType = tag2TypeMap.get(tag);
if (targetType == null) {
logger.warn(String.format("Dictionary tag '%s' is not mapped to any annotation type", tag));
} else {
AnnotationFS anno = cas.createAnnotation(targetType, firstToken.getBegin(), lastToken.getEnd());
Feature firstTokenFeature = targetType.getFeatureByBaseName("firstToken");
// TODO doc
if (firstTokenFeature != null) {
anno.setFeatureValue(firstTokenFeature, firstToken);
}
cas.addFsToIndexes(anno);
}
}
示例7: simpleCopyToDiffExistingAnnoWithNoStackingTest
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
@Test
public void simpleCopyToDiffExistingAnnoWithNoStackingTest()
throws Exception
{
JCas jcas = JCasFactory.createJCas();
Type type = jcas.getTypeSystem().getType(POS.class.getTypeName());
AnnotationFS clickedFs = createPOSAnno(jcas, type, "NN", 0, 0);
JCas mergeCAs = JCasFactory.createJCas();
AnnotationFS existingFs = mergeCAs.getCas().createAnnotation(type, 0, 0);
Feature posValue = type.getFeatureByBaseName("PosValue");
existingFs.setStringValue(posValue, "NE");
mergeCAs.addFsToIndexes(existingFs);
MergeCas.addSpanAnnotation(new AnnotatorStateImpl(Mode.CURATION), annotationSchemaService,
posLayer, mergeCAs, clickedFs, false);
assertEquals(1, CasUtil.selectCovered(mergeCAs.getCas(), type, 0, 0).size());
}
示例8: delete
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
@Override
public void delete(AnnotatorState aState, JCas aJCas, VID aVid)
{
AnnotationFS fs = selectByAddr(aJCas, AnnotationFS.class, aVid.getId());
aJCas.removeFsFromIndexes(fs);
// delete associated attachFeature
if (getAttachTypeName() != null) {
Type theType = CasUtil.getType(aJCas.getCas(), getAttachTypeName());
Feature attachFeature = theType.getFeatureByBaseName(getAttachFeatureName());
if (attachFeature != null) {
CasUtil.selectCovered(aJCas.getCas(), theType, fs.getBegin(), fs.getEnd()).get(0)
.setFeatureValue(attachFeature, null);
}
}
publishEvent(new SpanDeletedEvent(this, aState.getDocument(),
aState.getUser().getUsername(), fs));
}
示例9: isRelationLayer
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
public static boolean isRelationLayer(Type aType)
{
Feature relSourceFeat = aType.getFeatureByBaseName(FEAT_REL_SOURCE);
boolean hasSourceFeature = relSourceFeat != null && !isPrimitiveFeature(relSourceFeat);
Feature relTargetFeat = aType.getFeatureByBaseName(FEAT_REL_TARGET);
boolean hasTargetFeature = relTargetFeat != null && !isPrimitiveFeature(relTargetFeat);
boolean compatible = true;
for (Feature feat : aType.getFeatures()) {
if (
CAS.FEATURE_BASE_NAME_SOFA.equals(feat.getShortName()) ||
FEAT_REL_SOURCE.equals(feat.getShortName()) ||
FEAT_REL_TARGET.equals(feat.getShortName())
) {
continue;
}
if (!isPrimitiveFeature(feat)) {
compatible = false;
//LOG.debug("Incompatible feature in type [" + aType + "]: " + feat);
break;
}
}
return hasSourceFeature && hasTargetFeature && compatible;
}
示例10: addChainAnnotations
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
/**
* The individual link annotations are stored in a {@link TreeMap} (chainAnnosPerTye) with chain
* number and link number references, sorted in an ascending order <br>
* Iterate over each chain number and link number references and construct the chain.
*/
private void addChainAnnotations(JCas aJCas)
{
for (Type linkType : chainAnnosPerTyep.keySet()) {
for (int chainNo : chainAnnosPerTyep.get(linkType).keySet()) {
Type chainType = aJCas.getCas().getTypeSystem().getType(
linkType.getName().substring(0, linkType.getName().length() - 4) + CHAIN);
Feature firstF = chainType.getFeatureByBaseName(FIRST);
Feature nextF = linkType.getFeatureByBaseName(NEXT);
FeatureStructure chain = aJCas.getCas().createFS(chainType);
aJCas.addFsToIndexes(chain);
AnnotationFS firstFs = chainAnnosPerTyep.get(linkType).get(chainNo).get(1);
AnnotationFS linkFs = firstFs;
chain.setFeatureValue(firstF, firstFs);
for (int i = 2; i <= chainAnnosPerTyep.get(linkType).get(chainNo).size(); i++) {
linkFs.setFeatureValue(nextF,
chainAnnosPerTyep.get(linkType).get(chainNo).get(i));
linkFs = chainAnnosPerTyep.get(linkType).get(chainNo).get(i);
}
}
}
}
示例11: copySpanAnnotation
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
/**
* Copy this same annotation from the user annotation to the mergeview
*/
public static void copySpanAnnotation(AnnotatorState aState,
AnnotationSchemaService aAnnotationService, AnnotationLayer aAnnotationLayer,
AnnotationFS aOldFs, JCas aJCas)
throws AnnotationException
{
SpanAdapter adapter = (SpanAdapter) aAnnotationService.getAdapter(aAnnotationLayer);
// Create the annotation - this also takes care of attaching to an annotation if necessary
int id = adapter.add(aState, aJCas, aOldFs.getBegin(), aOldFs.getEnd());
List<AnnotationFeature> features = aAnnotationService
.listAnnotationFeature(adapter.getLayer());
// Copy the features
for (AnnotationFeature feature : features) {
Type oldType = adapter.getAnnotationType(aOldFs.getCAS());
Feature oldFeature = oldType.getFeatureByBaseName(feature.getName());
if (isLinkOrBasicFeatures(aOldFs, oldFeature)) {
continue;
}
Object value = adapter.getFeatureValue(feature, aOldFs);
adapter.setFeatureValue(aState, aJCas, id, feature, value);
}
}
示例12: copyRelationAnnotation
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
public static void copyRelationAnnotation(AnnotationFS aOldFs, AnnotationFS asourceFS,
AnnotationFS aTargetFs, JCas aJCas)
{
Feature[] features = getAllFeatures(aOldFs);
Type type = aOldFs.getType();
Feature sourceFeat = type.getFeatureByBaseName(WebAnnoConst.FEAT_REL_SOURCE);
Feature targetFeat = type.getFeatureByBaseName(WebAnnoConst.FEAT_REL_TARGET);
AnnotationFS newFs = aJCas.getCas().createAnnotation(type, aOldFs.getBegin(),
aOldFs.getEnd());
for (Feature f : features) {
if (isLinkOrBasicFeatures(aOldFs, f)) {
continue;
}
if (f.equals(sourceFeat)) {
newFs.setFeatureValue(f, asourceFS);
}
else if (f.equals(targetFeat)) {
newFs.setFeatureValue(f, aTargetFs);
}
else {
setFeatureValue(newFs, f, getFeatureValue(aOldFs, f));
}
}
aJCas.addFsToIndexes(newFs);
}
示例13: annotate
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
private void annotate(JCas jcas, Type type, TreeMatch match, EntryMetadata metadata) {
AnnotationFS annotation =
jcas.getCas().createAnnotation(type, match.getStart(), match.getEnd());
String[] columns = metadata.getColumns();
for (Map.Entry<Integer,String> fi : featureIndexes.entrySet()) {
if (columns.length > fi.getKey()) {
Feature feature = type.getFeatureByBaseName(fi.getValue());
annotation.setFeatureValueFromString(feature, columns[fi.getKey()]);
}
}
jcas.getCas().addFsToIndexes(annotation);
}
示例14: fromCAS
import org.apache.uima.cas.Type; //导入方法依赖的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;
}
示例15: process
import org.apache.uima.cas.Type; //导入方法依赖的package包/类
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
Type type = jcas.getCas().getTypeSystem().getType(TYPE_NAME);
Feature posFeature = type.getFeatureByBaseName(FEATURE_NAME);
for (Annotation annotation : jcas.getAnnotationIndex(type)) {
String text = annotation.getCoveredText();
String pos = extractPoS(text);
annotation.setStringValue(posFeature, pos);
}
}