本文整理了Java中org.apache.uima.jcas.tcas.Annotation.getType()
方法的一些代码示例,展示了Annotation.getType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.getType()
方法的具体详情如下:
包路径:org.apache.uima.jcas.tcas.Annotation
类名称:Annotation
方法名:getType
暂无
代码示例来源:origin: de.unistuttgart.ims/cleartk-util
public List<Feature> extract(JCas view, T focusAnnotation) throws CleartkExtractorException {
List<Feature> flist = new LinkedList<Feature>();
for (Annotation anno : JCasUtil.select(view, goalClass)) {
Feature f = new Feature();
f.setName("subtype");
f.setValue(anno.getType().getShortName());
flist.add(f);
}
return flist;
}
代码示例来源:origin: org.dkpro.argumentation/dkpro-argumentation-io
private static String createStrRepr(final Annotation source)
{
return String.format("[%d, %d, %s]", source.getBegin(), source.getEnd(),
source.getType().getShortName());
}
代码示例来源:origin: de.tudarmstadt.ukp.teaching.uima/de.tudarmstadt.ukp.teaching.uima.lesson1
@Override
public void process(JCas aJCas) throws AnalysisEngineProcessException {
DocumentMetaData meta = iterate(aJCas, DocumentMetaData.class).iterator().next();
System.out.println("=== METADATA ========================================");
System.out.println("URI : "+meta.getDocumentUri());
System.out.println("Language: "+aJCas.getDocumentLanguage());
System.out.println("=== TEXT ============================================");
System.out.println(aJCas.getDocumentText());
System.out.println("=== ANNOTATIONS =====================================");
for (Annotation a : iterate(aJCas, Annotation.class)) {
System.out.println(a.getType().getName() + "(" + a.getBegin() + ","
+ a.getEnd() + ") [" + a.getCoveredText() + "]");
}
}
}
代码示例来源:origin: org.apache.uima/ruta-core
public RutaAnnotation getCorrectTMA(List<AnnotationFS> annotationsInWindow,
RutaAnnotation heuristicAnnotation) {
for (AnnotationFS annotation : annotationsInWindow) {
if (annotation instanceof RutaAnnotation) {
RutaAnnotation tma = (RutaAnnotation) annotation;
if (tma.getBegin() == heuristicAnnotation.getBegin()
&& tma.getEnd() == heuristicAnnotation.getEnd() && tma.getAnnotation().getType()
.equals(heuristicAnnotation.getAnnotation().getType())) {
return tma;
}
}
}
return null;
}
代码示例来源:origin: fr.univ-nantes.julestar/uima-test
private List<Annotation> getAnnotationList(Type... annotationTypes) {
List<Annotation> list = Lists.newArrayList();
FSIterator<Annotation> it = actual.getAnnotationIndex().iterator();
while(it.hasNext()) {
Annotation a = it.next();
if(annotationTypes.length == 0)
list.add(a);
else
for(Type type:annotationTypes)
if(type.equals(a.getType()))
list.add(a);
}
return list;
}
代码示例来源:origin: dstl/baleen
@Override
public Type getType() {
return new Annotation(jCas).getType();
}
}
代码示例来源:origin: uk.gov.dstl.baleen/baleen-uima
@Override
public String getTypeName() {
if (getItem() == null) {
return "Root";
} else {
return getItem().getType().getShortName();
}
}
代码示例来源:origin: org.apache.uima/textmarker-core
public TextMarkerAnnotation getCorrectTMA(List<AnnotationFS> annotationsInWindow,
TextMarkerAnnotation heuristicAnnotation) {
for (AnnotationFS annotation : annotationsInWindow) {
if (annotation instanceof TextMarkerAnnotation) {
TextMarkerAnnotation tma = (TextMarkerAnnotation) annotation;
if (tma.getBegin() == heuristicAnnotation.getBegin()
&& tma.getEnd() == heuristicAnnotation.getEnd()
&& tma.getAnnotation().getType()
.equals(heuristicAnnotation.getAnnotation().getType())) {
return tma;
}
}
}
return null;
}
代码示例来源:origin: apache/ctakes
/**
* @param annotation -
* @return annotation type and covered text in a fhir codeable concept.
*/
static public CodeableConcept createSimpleCode( final org.apache.uima.jcas.tcas.Annotation annotation ) {
final String type = annotation.getType()
// .getShortName();
.getName();
return createSimpleCode( CODING_TYPE_SYSTEM, type, null, annotation.getCoveredText() );
}
代码示例来源:origin: dstl/baleen
@Override
public String getTypeName() {
if (getItem() == null) {
return "Root";
} else {
return getItem().getType().getShortName();
}
}
代码示例来源:origin: org.apache.ctakes/ctakes-ne-contexts
protected List<Annotation> getMiddleScopeContextAnnotations(JCas jCas, Annotation focus)
throws AnalysisEngineProcessException {
List<Annotation> scopeContextAnnotations = new ArrayList<Annotation>();
FSIterator subiterator = jCas.getAnnotationIndex(contextType).subiterator(focus);
while (subiterator.hasNext()) {
scopeContextAnnotations.add((Annotation) subiterator.next());
}
if (scopeContextAnnotations.size() == 0 && JCasUtil.getType(focus.getClass()) == contextType)
scopeContextAnnotations.add(focus);
else if (scopeContextAnnotations.size() == 0) {
TypeSystem typeSystem = jCas.getTypeSystem();
Type superType = jCas.getType(focusType).casType;
Type subType = focus.getType();
if (typeSystem.subsumes(superType, subType))
scopeContextAnnotations.add(focus);
}
return scopeContextAnnotations;
}
代码示例来源:origin: apache/ctakes
protected List<Annotation> getMiddleScopeContextAnnotations(JCas jCas, Annotation focus)
throws AnalysisEngineProcessException {
List<Annotation> scopeContextAnnotations = new ArrayList<Annotation>();
FSIterator subiterator = jCas.getAnnotationIndex(contextType).subiterator(focus);
while (subiterator.hasNext()) {
scopeContextAnnotations.add((Annotation) subiterator.next());
}
if (scopeContextAnnotations.size() == 0 && JCasUtil.getType(focus.getClass()) == contextType)
scopeContextAnnotations.add(focus);
else if (scopeContextAnnotations.size() == 0) {
TypeSystem typeSystem = jCas.getTypeSystem();
Type superType = jCas.getType(focusType).casType;
Type subType = focus.getType();
if (typeSystem.subsumes(superType, subType))
scopeContextAnnotations.add(focus);
}
return scopeContextAnnotations;
}
代码示例来源:origin: de.unistuttgart.ims/uimautil
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
Set<Annotation> toDelete = null;
if (deleteSource) {
toDelete = new HashSet<Annotation>();
}
for (Annotation anno : JCasUtil.select(jcas, sourceClass)) {
Annotation newAnnotation = AnnotationFactory.createAnnotation(jcas, anno.getBegin(), anno.getEnd(),
targetClass);
if (deleteSource)
toDelete.add(anno);
if (!(targetFeatureName.isEmpty() || targetFeatureValue.isEmpty())) {
Feature feature = newAnnotation.getType().getFeatureByBaseName(targetFeatureName);
if (feature != null)
newAnnotation.setFeatureValueFromString(feature, targetFeatureValue);
}
}
if (deleteSource) {
for (Annotation a : toDelete) {
a.removeFromIndexes();
}
}
}
代码示例来源:origin: apache/ctakes
static private String getDebugText( final Annotation a ) {
return a.getType().getShortName() + "(" + a.getBegin() + "-" + a.getEnd() + "): " + a.getCoveredText();
}
代码示例来源:origin: org.dkpro.argumentation/dkpro-argumentation-io
private static int getAnnotationId(final Annotation source,
final Sparse3DObjectMatrix<String, ImmutableSpanTextLabel> spanAnnotationMatrix,
final Object2IntMap<ImmutableSpanTextLabel> spanAnnotationIds)
{
final int begin = source.getBegin();
final int end = source.getEnd();
final String label = source.getType().getShortName();
final SpanTextLabel spanAnnotation = spanAnnotationMatrix.get3DValue(begin, end, label);
return spanAnnotation == null ? -1 : spanAnnotationIds.getInt(spanAnnotation);
}
代码示例来源:origin: ch.epfl.bbp.nlp/bluima_mongodb
private void processAnnotaion(Annotation a,
Map<String, BasicDBList> dbLists, String typeName) {
MongoFieldMapping fieldMapping = ALL_MAPPINGS.get(typeName);
BasicDBList dbList; // getOrElseCreate
if (dbLists.containsKey(fieldMapping.shortName)) {
dbList = dbLists.get(fieldMapping.shortName);
} else {
dbList = new BasicDBList();
dbLists.put(fieldMapping.shortName, dbList);
}
BasicDBObject o = new BasicDBObject();
dbList.add(o);
o.put(BEGIN, a.getBegin());
o.put(END, a.getEnd());
Type t = a.getType();
for (Feature f : t.getFeatures()) {
if (fieldMapping.fieldMappings.containsKey(f.getShortName())) {
String dbKey = fieldMapping.fieldMappings.get(f.getShortName());
MongoFieldMapping.writeFieldToDb(f.getRange().getShortName(),
o, a, dbKey, f);
}
}
}
}
代码示例来源:origin: org.dkpro.argumentation/dkpro-argumentation-io
@Override
public ImmutableSpanTextLabel apply(final Annotation annotation)
{
final ImmutableSpan span = new ImmutableSpan(annotation.getBegin(), annotation.getEnd());
final ImmutableSpanText spanText = new ImmutableSpanText(span, annotation.getCoveredText());
final Map<Attribute, Object> attrs = createAttrMap(annotation);
return new ImmutableSpanTextLabel(spanText, annotation.getType().getShortName(), attrs);
}
代码示例来源:origin: uk.gov.dstl.baleen/baleen-uima
/**
* Add an annotation to the JCas index, notifying UimaMonitor of the fact we have done so
*
* @param annot Annotation(s) to add
*/
public void add(Collection<? extends Annotation> annotations) {
for (Annotation annot : annotations) {
annot.addToIndexes();
monitor.entityAdded(annot.getType().getName());
if (annot instanceof Entity) {
Entity entity = (Entity) annot;
// Add in a value if it doesn't have one
if (Strings.isNullOrEmpty(entity.getValue())) {
entity.setValue(annot.getCoveredText());
}
addToHistory(annot.getCAS(), HistoryEvents.createAdded((Recordable) annot, referrer));
}
}
}
代码示例来源:origin: dstl/baleen
/**
* Add an annotation to the JCas index, notifying UimaMonitor of the fact we have done so
*
* @param annot Annotation(s) to add
*/
public void add(Collection<? extends Annotation> annotations) {
for (Annotation annot : annotations) {
annot.addToIndexes();
monitor.entityAdded(annot.getType().getName());
if (annot instanceof Entity) {
Entity entity = (Entity) annot;
// Add in a value if it doesn't have one
if (Strings.isNullOrEmpty(entity.getValue())) {
entity.setValue(annot.getCoveredText());
}
addToHistory(annot.getCAS(), HistoryEvents.createAdded((Recordable) annot, referrer));
}
}
}
代码示例来源:origin: dstl/baleen
@Test
public void testRecordable() throws UIMAException {
JCas jCas = JCasFactory.createJCas();
FakeRecordable fakeRecordable = new FakeRecordable(jCas);
assertEquals(new Annotation(jCas).getType().getName(), fakeRecordable.getTypeName());
}
内容来源于网络,如有侵权,请联系作者删除!