本文整理汇总了Java中org.apache.uima.cas.FeatureStructure.getType方法的典型用法代码示例。如果您正苦于以下问题:Java FeatureStructure.getType方法的具体用法?Java FeatureStructure.getType怎么用?Java FeatureStructure.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.uima.cas.FeatureStructure
的用法示例。
在下文中一共展示了FeatureStructure.getType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getValueOfFS
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
@Override
public UimaPrimitive getValueOfFS(TypeSystem typeSystem, FeatureStructure targetFS) throws NlpTabException {
Collection<Object> values = new LinkedList<>();
FeatureStructure pointer = targetFS;
while (pointer.getType().getName().equals(nonEmptyName)) {
Object value;
try {
value = headMethod.invoke(pointer, headFeature);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new NlpTabException(e);
}
values.add(value);
pointer = pointer.getFeatureValue(tailFeature);
}
Type type = targetFS.getType();
String typeShortName = type.getShortName();
return new UimaPrimitive(values, typeShortName);
}
示例2: writeFS
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
/**
* Write an annotation to the file.
*
* @param generator
* the generator
* @param annotation
* the annotation
* @throws IOException
* Signals that an I/O exception has occurred.
*/
private void writeFS(JsonGenerator generator, FeatureStructure annotation) throws IOException {
generator.writeStartObject();
Type type = annotation.getType();
generator.writeStringField("type", type.getName());
List<Feature> features = type.getFeatures();
if (annotation instanceof AnnotationFS) {
AnnotationFS annotationFS = (AnnotationFS) annotation;
if (!(annotationFS.getEnd() == 0 && annotationFS.getBegin() == 0)) {
generator.writeStringField("coveredText", annotationFS.getCoveredText());
}
}
if (!features.isEmpty()) {
writeFS(generator, annotation, features);
}
generator.writeEndObject();
}
示例3: setAllRoleAnnosOnPosition
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
private static void setAllRoleAnnosOnPosition(Map<String, JCas> aJCases,
Map<String, ArrayFS> slotAnnosPerUser, Set<String> aUsers, FeatureStructure aBaseAnno,
Feature aFeature)
{
Type t = aBaseAnno.getType();
int begin = ((AnnotationFS) aBaseAnno).getBegin();
int end = ((AnnotationFS) aBaseAnno).getEnd();
for (String usr : aUsers) {
for (FeatureStructure baseFS : CasUtil.selectCovered(aJCases.get(usr).getCas(), t,
begin, end)) {
// if non eqal stacked annotations with slot feature exists, get
// the right one
if (isSameAnno(aBaseAnno, baseFS)) {
ArrayFS roleFs = (ArrayFS) WebAnnoCasUtil.getFeatureFS(baseFS,
aFeature.getShortName());
slotAnnosPerUser.put(usr, roleFs);
break;
}
}
}
}
示例4: verify
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
@Override
public boolean verify(FeatureStructure featureStructure, ParsedConstraints parsedConstraints)
{
boolean isOk = false;
Type type = featureStructure.getType();
for (Feature feature : type.getFeatures()) {
if (feature.getRange().isPrimitive()) {
String scopeName = featureStructure.getFeatureValueAsString(feature);
List<Rule> rules = parsedConstraints.getScopeByName(scopeName).getRules();
// Check if all the feature values are ok according to the
// rules;
}
else {
// Here some recursion would be in order
}
}
return isOk;
}
示例5: willProcess
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
@Override
public void willProcess(FeatureStructure featureStructure, TypeSystemInfo typeSystemInfo) throws NlpTabException {
Type type = featureStructure.getType();
TypeSystem typeSystem = featureStructure.getCAS().getTypeSystem();
Type typePointer = type;
while (typePointer != null && !typesSeen.contains(typePointer.getName())) {
typesSeen.add(typePointer.getName());
uploadType(typeSystemInfo, typeSystem, typePointer);
typePointer = typeSystem.getParent(typePointer);
}
}
示例6: getIdentifierForFs
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
public String getIdentifierForFs(FeatureStructure featureStructure) throws InterruptedException {
int fsRef = featureStructure.getCAS().getLowLevelCAS().ll_getFSRef(featureStructure);
Type type = featureStructure.getType();
if (type == null) {
throw new IllegalArgumentException("type was null");
}
String typeName = type.getName();
String identifier = identifierForFsRef.get(fsRef);
boolean newlyCreated = false;
if (identifier == null) {
synchronized (this) {
identifier = identifierForFsRef.get(fsRef);
if (identifier == null) {
identifier = Strings.base64UUID();
identifierForFsRef.put(fsRef, identifier);
}
newlyCreated = true;
}
}
if (newlyCreated && typeFilter.apply(typeName)) {
fsRefQueue.put(fsRef);
}
return identifier;
}
示例7: getFSAtPosition
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
/**
* Returns list of Annotations on this particular position (basically when stacking is allowed).
*/
private static List<FeatureStructure> getFSAtPosition(Map<String, JCas> aJCases,
FeatureStructure fs, String aUser)
{
Type t = fs.getType();
int begin = ((AnnotationFS) fs).getBegin();
int end = ((AnnotationFS) fs).getEnd();
List<FeatureStructure> fssAtThisPosition = new ArrayList<>();
fssAtThisPosition.addAll(CasUtil.selectCovered(aJCases.get(aUser).getCas(), t, begin, end));
return fssAtThisPosition;
}
示例8: getPosition
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
@Override
public Position getPosition(int aCasId, FeatureStructure aFS, String aFeature, String aRole,
int aLinkTargetBegin, int aLinkTargetEnd, LinkCompareBehavior aLinkCompareBehavior)
{
Type type = aFS.getType();
AnnotationFS sourceFS = (AnnotationFS) aFS.getFeatureValue(type
.getFeatureByBaseName(sourceFeature));
AnnotationFS targetFS = (AnnotationFS) aFS.getFeatureValue(type
.getFeatureByBaseName(targetFeature));
String collectionId = null;
String documentId = null;
try {
DocumentMetaData dmd = DocumentMetaData.get(aFS.getCAS());
collectionId = dmd.getCollectionId();
documentId = dmd.getDocumentId();
}
catch (IllegalArgumentException e) {
// We use this information only for debugging - so we can ignore if the information
// is missing.
}
String linkTargetText = null;
if (aLinkTargetBegin != -1 && aFS.getCAS().getDocumentText() != null) {
linkTargetText = aFS.getCAS().getDocumentText()
.substring(aLinkTargetBegin, aLinkTargetEnd);
}
return new ArcPosition(collectionId, documentId, aCasId, getType(),
sourceFS != null ? sourceFS.getBegin() : -1,
sourceFS != null ? sourceFS.getEnd() : -1,
sourceFS != null ? sourceFS.getCoveredText() : null,
targetFS != null ? targetFS.getBegin() : -1,
targetFS != null ? targetFS.getEnd() : -1,
targetFS != null ? targetFS.getCoveredText() : null,
aFeature, aRole, aLinkTargetBegin, aLinkTargetEnd, linkTargetText,
aLinkCompareBehavior);
}
示例9: buildRequest
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
@Override
public IndexRequestBuilder buildRequest(String primaryIndex, SofaData sofaData, FeatureStructure featureStructure) throws IOException, NlpTabException, InterruptedException {
Type type = featureStructure.getType();
if (type == null) {
throw new IllegalStateException();
}
CAS cas = featureStructure.getCAS();
TypeSystem typeSystem = cas.getTypeSystem();
if (typeSystem == null) {
throw new IllegalStateException();
}
XContentBuilder builder = XContentFactory.jsonBuilder()
.startObject()
.field("system", primaryIndex)
.field("casIdentifier", sofaData.getCasIdentifierString())
.field("casViewIdentifier", sofaData.getCasViewIdentifierString())
.field("documentIdentifier", sofaData.getDocumentIdentifierString())
.field("primaryType", type.getName());
builder.startArray("types");
Type parentType = type;
while (parentType != null) {
builder.value(parentType.getName());
parentType = typeSystem.getParent(parentType);
}
builder.endArray();
if (primitiveValue != null) {
builder.field("items", primitiveValue.getValueOrNull());
}
if (listItems != null) {
builder.array("listItems", listItems.toArray());
}
if (arrayItems != null) {
builder.array("arrayItems", arrayItems.toArray());
}
if (primitiveFeatureInstances != null) {
Set<String> primitiveFeatureInstanceIds = primitiveFeatureInstances.keySet();
for (String valueTypeKey : primitiveFeatureInstanceIds) {
builder.startObject(valueTypeKey + "Features");
Collection<PrimitiveFeatureInstance> valuePrimitiveFeatures = primitiveFeatureInstances.get(valueTypeKey);
if (valuePrimitiveFeatures != null) {
for (PrimitiveFeatureInstance primitiveFeatureInstance : valuePrimitiveFeatures) {
String name = primitiveFeatureInstance.getLuceneSafeFeatureName();
Object valueOrNull = primitiveFeatureInstance.getValueOfFeature().getValueOrNull();
builder.field(name, valueOrNull);
}
}
builder.endObject();
}
}
if (referenceFeatureInstances != null) {
builder.startObject("references");
for (ReferenceFeatureInstance referenceFeatureInstance : referenceFeatureInstances) {
String featureName = referenceFeatureInstance.getLuceneSafeFeatureName();
String referenceId = referenceFeatureInstance.getReferenceId();
builder.field(featureName, referenceId);
}
builder.endObject();
}
return client.prepareIndex(primaryIndex, "FeatureStructure")
.setId(sofaData.getIdentifierForFs(featureStructure))
.setSource(builder.endObject());
}
示例10: FsAccessor
import org.apache.uima.cas.FeatureStructure; //导入方法依赖的package包/类
public FsAccessor(FeatureStructure featureStructure) {
this.featureStructure = featureStructure;
type = featureStructure.getType();
}