本文整理了Java中org.apache.uima.cas.CAS.getAnnotationType()
方法的一些代码示例,展示了CAS.getAnnotationType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CAS.getAnnotationType()
方法的具体详情如下:
包路径:org.apache.uima.cas.CAS
类名称:CAS
方法名:getAnnotationType
[英]Get the type object for the annotation type.
[中]获取注释类型的类型对象。
代码示例来源:origin: org.apache.uima/ruta-core
@Override
public Type getType(RutaBlock parent, RutaStream stream) {
return stream.getCas().getAnnotationType();
}
代码示例来源:origin: org.apache.uima/ruta-core
public Type getSharedParentType(List<Type> types) {
if (types == null || types.isEmpty()) {
return cas.getAnnotationType();
}
if (types.size() == 1) {
return types.get(0);
}
TypeSystem typeSystem = cas.getTypeSystem();
Type parentType = types.get(0);
for (Type type : types) {
parentType = getSharedParentType(parentType, type, typeSystem);
}
return parentType;
}
代码示例来源:origin: org.apache.uima/ruta-core
private Type getSharedParentType(Type type1, Type type2, TypeSystem typeSystem) {
if (cas.getAnnotationType().equals(type1) || cas.getAnnotationType().equals(type2)) {
return cas.getAnnotationType();
}
if (type1.equals(type2)) {
return type1;
}
if (typeSystem.subsumes(type1, type2)) {
return type1;
}
if (typeSystem.subsumes(type2, type1)) {
return type2;
}
Type parentType = typeSystem.getParent(type1);
while (parentType != null && !cas.getAnnotationType().equals(parentType)) {
if (typeSystem.subsumes(parentType, type2)) {
return parentType;
}
}
return cas.getAnnotationType();
}
}
代码示例来源:origin: org.apache.uima/ruta-core
return annotationTypeDummy;
} else {
return cas.getAnnotationType();
代码示例来源:origin: org.apache.uima/uimafit-core
/**
* Get the CAS type for the given JCas wrapper class making sure it is or inherits from
* {@link Annotation}.
*
* @param aCas
* the CAS hosting the type system.
* @param aJCasClass
* the JCas wrapper class.
* @return the CAS type.
*/
public static Type getAnnotationType(CAS aCas, Class<?> aJCasClass) {
final Type type = getType(aCas, aJCasClass);
if (!aCas.getTypeSystem().subsumes(aCas.getAnnotationType(), type)) {
throw new IllegalArgumentException("Type [" + aJCasClass.getName()
+ "] is not an annotation type");
}
return type;
}
代码示例来源:origin: org.apache.uima/textmarker-core
public <T> T getVariableValue(String name, Class<T> type) {
boolean containsKey = variableValues.containsKey(name);
Object result = variableValues.get(name);
if (containsKey && result == null) {
// TODO find the problem with the null values!
// this might now work for word lists in another env.
return type.cast(getInitialValue(name, type));
}
if (result == annotationTypeDummy) {
return type.cast(cas.getAnnotationType());
}
if (result != null) {
return type.cast(result);
} else if (owner.getParent() != null) {
return owner.getParent().getEnvironment().getVariableValue(name, type);
}
return null;
}
代码示例来源:origin: org.apache.uima/uimafit-core
/**
* Get the CAS type for the given name making sure it is or inherits from Annotation.
*
* @param aCas
* the CAS hosting the type system.
* @param aTypeName
* the fully qualified type name.
* @return the CAS type.
*/
public static Type getAnnotationType(CAS aCas, String aTypeName) {
Type type = getType(aCas, aTypeName);
if (!aCas.getTypeSystem().subsumes(aCas.getAnnotationType(), type)) {
throw new IllegalArgumentException("Type [" + aTypeName + "] is not an annotation type");
}
return type;
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.testing-asl
public static Set<FeatureStructure> getNonIndexedFSes(CAS aCas)
{
TypeSystem ts = aCas.getTypeSystem();
Set<FeatureStructure> allIndexedFS = collectIndexed(aCas);
Set<FeatureStructure> allReachableFS = collectReachable(aCas);
// Remove all that are indexed
allReachableFS.removeAll(allIndexedFS);
// Remove all that are not annotations
allReachableFS.removeIf(fs -> !ts.subsumes(aCas.getAnnotationType(), fs.getType()));
// All that is left are non-index annotations
return allReachableFS;
}
代码示例来源:origin: dkpro/dkpro-core
public static Set<FeatureStructure> getNonIndexedFSes(CAS aCas)
{
TypeSystem ts = aCas.getTypeSystem();
Set<FeatureStructure> allIndexedFS = collectIndexed(aCas);
Set<FeatureStructure> allReachableFS = collectReachable(aCas);
// Remove all that are indexed
allReachableFS.removeAll(allIndexedFS);
// Remove all that are not annotations
allReachableFS.removeIf(fs -> !ts.subsumes(aCas.getAnnotationType(), fs.getType()));
// All that is left are non-index annotations
return allReachableFS;
}
代码示例来源:origin: webanno/webanno
public static Set<FeatureStructure> getNonIndexedFSes(CAS aCas)
{
TypeSystem ts = aCas.getTypeSystem();
Set<FeatureStructure> allIndexedFS = collectIndexed(aCas);
Set<FeatureStructure> allReachableFS = collectReachable(aCas);
// Remove all that are indexed
allReachableFS.removeAll(allIndexedFS);
// Remove all that are not annotations
allReachableFS.removeIf(fs -> !ts.subsumes(aCas.getAnnotationType(), fs.getType()));
// All that is left are non-index annotations
return allReachableFS;
}
代码示例来源:origin: webanno/webanno
public static Map<FeatureStructure, FeatureStructure> getNonIndexedFSesWithOwner(CAS aCas)
{
TypeSystem ts = aCas.getTypeSystem();
LowLevelCAS llcas = aCas.getLowLevelCAS();
Set<FeatureStructure> allIndexedFS = collectIndexed(aCas);
Map<FeatureStructure, FeatureStructure> allReachableFS = new TreeMap<>(
Comparator.comparingInt(llcas::ll_getFSRef));
FSIterator<FeatureStructure> i = aCas.getIndexRepository().getAllIndexedFS(
aCas.getTypeSystem().getTopType());
i.forEachRemaining(fs -> collect(allReachableFS, allIndexedFS, fs, fs));
// Remove all that are not annotations
allReachableFS.entrySet().removeIf(e ->
!ts.subsumes(aCas.getAnnotationType(), e.getKey().getType()));
// Remove all that are indexed
allReachableFS.entrySet().removeIf(e -> e.getKey() == e.getValue());
// All that is left are non-index annotations
return allReachableFS;
}
}
代码示例来源:origin: org.apache.uima/uimafit-core
/**
* Convenience method to iterator over all annotations of a given type.
*
* @param cas
* the CAS containing the type system.
* @param type
* the type.
* @return A collection of the selected type.
* @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a>
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Collection<AnnotationFS> select(final CAS cas, final Type type) {
if (!cas.getTypeSystem().subsumes(cas.getAnnotationType(), type)) {
throw new IllegalArgumentException("Type [" + type.getName() + "] is not an annotation type");
}
return (Collection) FSCollectionFactory.create(cas.getAnnotationIndex(type));
}
代码示例来源:origin: org.apache.uima/textmarker-core
private void doMatch(ComposedRuleElementMatch match, TextMarkerStream stream, InferenceCrowd crowd) {
List<AnnotationFS> textsMatched = match.getTextsMatched();
if (textsMatched == null || textsMatched.isEmpty()) {
return;
}
int begin = textsMatched.get(0).getBegin();
int end = textsMatched.get(textsMatched.size() - 1).getEnd();
AnnotationFS annotation = stream.getCas().createAnnotation(stream.getCas().getAnnotationType(),
begin, end);
List<EvaluatedCondition> evaluatedConditions = new ArrayList<EvaluatedCondition>(
conditions.size());
for (AbstractTextMarkerCondition condition : conditions) {
crowd.beginVisit(condition, null);
EvaluatedCondition eval = condition.eval(annotation, this, stream, crowd);
crowd.endVisit(condition, null);
evaluatedConditions.add(eval);
}
match.setConditionInfo(evaluatedConditions);
match.evaluateInnerMatches(true);
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.testing-asl
public static Map<FeatureStructure, FeatureStructure> getNonIndexedFSesWithOwner(CAS aCas)
{
TypeSystem ts = aCas.getTypeSystem();
LowLevelCAS llcas = aCas.getLowLevelCAS();
Set<FeatureStructure> allIndexedFS = collectIndexed(aCas);
Map<FeatureStructure, FeatureStructure> allReachableFS = new TreeMap<>((fs1, fs2) ->
llcas.ll_getFSRef(fs1) - llcas.ll_getFSRef(fs2));
FSIterator<FeatureStructure> i = aCas.getIndexRepository().getAllIndexedFS(
aCas.getTypeSystem().getTopType());
i.forEachRemaining(fs -> collect(allReachableFS, allIndexedFS, fs, fs));
// Remove all that are not annotations
allReachableFS.entrySet()
.removeIf(e -> !ts.subsumes(aCas.getAnnotationType(), e.getKey().getType()));
// Remove all that are indexed
allReachableFS.entrySet().removeIf(e -> e.getKey() == e.getValue());
// All that is left are non-index annotations
return allReachableFS;
}
}
代码示例来源:origin: dkpro/dkpro-core
public static Map<FeatureStructure, FeatureStructure> getNonIndexedFSesWithOwner(CAS aCas)
{
TypeSystem ts = aCas.getTypeSystem();
LowLevelCAS llcas = aCas.getLowLevelCAS();
Set<FeatureStructure> allIndexedFS = collectIndexed(aCas);
Map<FeatureStructure, FeatureStructure> allReachableFS = new TreeMap<>((fs1, fs2) ->
llcas.ll_getFSRef(fs1) - llcas.ll_getFSRef(fs2));
FSIterator<FeatureStructure> i = aCas.getIndexRepository().getAllIndexedFS(
aCas.getTypeSystem().getTopType());
i.forEachRemaining(fs -> collect(allReachableFS, allIndexedFS, fs, fs));
// Remove all that are not annotations
allReachableFS.entrySet()
.removeIf(e -> !ts.subsumes(aCas.getAnnotationType(), e.getKey().getType()));
// Remove all that are indexed
allReachableFS.entrySet().removeIf(e -> e.getKey() == e.getValue());
// All that is left are non-index annotations
return allReachableFS;
}
}
代码示例来源:origin: org.apache.uima/uimafit-core
/**
* Convenience method to iterator over all annotations of a given type.
*
* @param array
* features structure array.
* @param type
* the type.
* @return A collection of the selected type.
* @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a>
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Collection<AnnotationFS> select(ArrayFS array, Type type) {
final CAS cas = array.getCAS();
if (!cas.getTypeSystem().subsumes(cas.getAnnotationType(), type)) {
throw new IllegalArgumentException("Type [" + type.getName() + "] is not an annotation type");
}
return (Collection) FSCollectionFactory.create(array, type);
}
代码示例来源:origin: org.apache.uima/ruta-ep-caseditor
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
Object element = event.getElement();
boolean checked = event.getChecked();
Type type = null;
if (element instanceof TypeTreeNode) {
type = ((TypeTreeNode) element).getType();
} else if (element instanceof AnnotationTreeNode) {
type = ((AnnotationTreeNode) element).getType();
}
Type modeType = editor.getAnnotationMode();
if(!checked && modeType != null && modeType.equals(type)) {
// reset mode to uima.tcas.Annotation if deselected
getTreeViewer().setGrayed(new TypeTreeNode(null, type), false);
Type annotationType = editor.getDocument().getCAS().getAnnotationType();
editor.setAnnotationMode(annotationType);
}
if (type != null && !editor.getAnnotationMode().equals(type)) {
editor.setShownAnnotationType(type, checked);
}
}
代码示例来源:origin: org.apache.uima/uimafit-core
/**
* Create a {@link Collection} of the given type of feature structures. This collection is backed
* by the CAS, either via an {@link CAS#getAnnotationIndex(Type)} or
* {@link FSIndexRepository#getAllIndexedFS(Type)}.
*
* @param cas
* the CAS to select from.
* @param type
* the type of feature structures to select. All sub-types are returned as well.
* @return a {@link Collection} of the given type of feature structures backed live by the CAS.
* @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a>
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Collection<FeatureStructure> create(CAS cas, Type type) {
// If the type is an annotation type, we can use the annotation index, which directly
// provides us with its size. If not, we have to use getAllIndexedFS() which we have to
// scan from beginning to end in order to determine its size.
TypeSystem ts = cas.getTypeSystem();
if (ts.subsumes(cas.getAnnotationType(), type)) {
return (Collection) create(cas.getAnnotationIndex(type));
} else {
return create(cas.getIndexRepository().getAllIndexedFS(type));
}
}
代码示例来源:origin: org.apache.uima/ruta-core
AnnotationFS annotation = stream.getCas().createAnnotation(stream.getCas().getAnnotationType(),
begin, end);
代码示例来源:origin: webanno/webanno
AnnotationFS anno1 = cas.createAnnotation(cas.getAnnotationType(), 0, 1);
cas.addFsToIndexes(anno1);
AnnotationFS anno2 = cas.createAnnotation(cas.getAnnotationType(), 0, 1);
内容来源于网络,如有侵权,请联系作者删除!