congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
UimaSupport
Code IndexAdd Tabnine to your IDE (free)

How to use
UimaSupport
in
uk.gov.dstl.baleen.uima

Best Java code snippets using uk.gov.dstl.baleen.uima.UimaSupport (Showing top 20 results out of 315)

origin: dstl/baleen

/**
 * Return the document annotation.
 *
 * @param jCas
 * @return the document annotation
 */
protected DocumentAnnotation getDocumentAnnotation(JCas jCas) {
 return UimaSupport.getDocumentAnnotation(jCas);
}
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(Annotation... annotations) {
 add(Arrays.asList(annotations));
}
origin: uk.gov.dstl.baleen/baleen-uima

/**
 * Adds a event to the history for this jcas document.
 *
 * @param jCas the target document for the event
 * @param event the event to add
 */
public void addToHistory(JCas jCas, HistoryEvent event) {
 getDocumentHistory(jCas).add(event);
}
origin: dstl/baleen

/**
 * Add a new annotation, which is merged from the old annotations, removing the old annotations.
 *
 * @param newAnnotation The annotation which is to be added to the document as the merged result
 *     of the old annotations
 * @param annotations Annotation(s) which have been merged and should be removed
 */
public void mergeWithNew(Annotation newAnnotation, Collection<? extends Annotation> annotations) {
 add(newAnnotation);
 mergeWithExisting(newAnnotation, annotations);
}
origin: uk.gov.dstl.baleen/baleen-collectionreaders

final DocumentAnnotation da = UimaSupport.getDocumentAnnotation(jCas);
da.setTimestamp(System.currentTimeMillis());
da.setDocType("re3d");
   a.setConfidence(e.getConfidence());
   getSupport().add(a);
   a.setSource(source.get());
   a.setTarget(target.get());
   getSupport().add(a);
origin: dstl/baleen

EntityRelationConverter entityRelationConverter =
  new EntityRelationConverter(
    monitor, false, support.getDocumentHistory(jCas), stopFeatures, fields);
DocumentAnnotation da = UimaSupport.getDocumentAnnotation(jCas);
output.putAll(createDocumentAnnotationMap(da));
origin: dstl/baleen

@Test
public void testMergeWithExistingAnnotationAnnotationArray() {
 UimaSupport support = new UimaSupport(PIPELINE, UimaSupportTest.class, history, monitor, false);
 Location l = new Location(jCas);
 l.setBegin(0);
 l.setEnd(0);
 l.addToIndexes();
 Metadata md2 = new Metadata(jCas);
 md2.setBegin(0);
 md2.setEnd(0);
 md2.addToIndexes();
 support.mergeWithExisting(l, location);
 support.mergeWithExisting(md2, md);
 List<Location> locations = new ArrayList<>(JCasUtil.select(jCas, Location.class));
 List<Metadata> mds = new ArrayList<>(JCasUtil.select(jCas, Metadata.class));
 assertEquals(1, locations.size());
 assertEquals(l, locations.get(0));
 assertEquals(1, mds.size());
 assertEquals(md2, mds.get(0));
 assertFalse(support.getDocumentHistory(jCas).getHistory(l.getInternalId()).isEmpty());
}
origin: dstl/baleen

verify(support, only()).add(annotation);
resetMocked();
verify(support, only()).add(list);
resetMocked();
verify(support, only()).mergeWithExisting(existingAnnotation, annotation);
resetMocked();
verify(support, only()).mergeWithExisting(existingAnnotation, list);
resetMocked();
verify(support, only()).mergeWithNew(existingAnnotation, annotation);
resetMocked();
verify(support, only()).mergeWithNew(existingAnnotation, list);
resetMocked();
verify(support, only()).remove(annotation);
resetMocked();
verify(support, only()).remove(list);
resetMocked();
origin: dstl/baleen

@Test
public void testAddAnnotationArray() {
 UimaSupport support = new UimaSupport(PIPELINE, UimaSupportTest.class, history, monitor, false);
 Person withValue = new Person(jCas);
 withValue.setBegin(0);
 withValue.setEnd(4);
 withValue.setValue("David");
 Person withoutValue = new Person(jCas);
 withoutValue.setBegin(0);
 withoutValue.setEnd(4);
 support.add(new ProtectiveMarking(jCas), withValue, withoutValue);
 assertEquals(1, JCasUtil.select(jCas, ProtectiveMarking.class).size());
 List<Person> persons = new ArrayList<Person>(JCasUtil.select(jCas, Person.class));
 assertEquals(2, persons.size());
 // Check value is set / not overridden
 assertNotEquals(persons.get(0).getCoveredText(), persons.get(0).getValue());
 assertEquals(persons.get(1).getCoveredText(), persons.get(1).getValue());
 // Check Id set
 assertNotEquals(persons.get(0).getInternalId(), persons.get(1).getInternalId());
 // Check had history of addition
 assertFalse(
   support.getDocumentHistory(jCas).getHistory(persons.get(1).getInternalId()).isEmpty());
}
origin: dstl/baleen

@Test
public void testRemoveAnnotationArray() {
 UimaSupport support = new UimaSupport(PIPELINE, UimaSupportTest.class, history, monitor, false);
 support.remove(location, md);
 assertEquals(0, JCasUtil.select(jCas, Location.class).size());
 assertEquals(0, JCasUtil.select(jCas, Metadata.class).size());
 // Location should not have history and id
 assertNotNull(location.getInternalId());
 assertFalse(support.getDocumentHistory(jCas).getHistory(location.getInternalId()).isEmpty());
}
origin: dstl/baleen

@Test
public void testMergeWithNewAnnotationAnnotationArray() {
 UimaSupport support = new UimaSupport(PIPELINE, UimaSupportTest.class, history, monitor, false);
 Location l = new Location(jCas);
 l.setBegin(0);
 l.setEnd(0);
 Metadata md2 = new Metadata(jCas);
 md2.setBegin(0);
 md2.setEnd(0);
 support.mergeWithNew(l, location);
 support.mergeWithNew(md2, md);
 List<Location> locations = new ArrayList<>(JCasUtil.select(jCas, Location.class));
 List<Metadata> mds = new ArrayList<>(JCasUtil.select(jCas, Metadata.class));
 assertEquals(1, locations.size());
 assertEquals(l, locations.get(0));
 assertEquals(1, mds.size());
 assertEquals(md2, mds.get(0));
 assertFalse(support.getDocumentHistory(jCas).getHistory(l.getInternalId()).isEmpty());
}
origin: dstl/baleen

/**
 * Merge entity onto targetEntity (assuming they have the same ReferentTarget), updating
 * relationships as required.
 *
 * @return True if merge was successful, false otherwise
 */
private boolean mergeEntities(Entity entity, Entity targetEntity) {
 ReferenceTarget targetRef = targetEntity.getReferent();
 ReferenceTarget entityRef = entity.getReferent();
 if (mergeDistinctEntities || isSameTarget(targetRef, entityRef)) {
  addMergeToHistory(targetEntity, entity);
  // Update relationship pointers
  for (Relation r : getRelations(entity)) {
   if (r.getSource() == entity) {
    r.setSource(targetEntity);
   }
   if (r.getTarget() == entity) {
    r.setTarget(targetEntity);
   }
  }
  remove(entity);
  return true;
 } else {
  monitor.debug(
    "Not merging objects {} and {} as they have different referents",
    targetEntity.getInternalId(),
    entity.getInternalId());
  return false;
 }
}
origin: uk.gov.dstl.baleen/baleen-uima

/**
 * Merge an existing annotation with old annotations, removing the old annotations.
 *
 * @param existingAnnotation The annotation which exists and is to be left in the document
 *     (merged)
 * @param annotations Annotation(s) which have been merged wiht existingAnnotation and then
 *     removed
 */
public void mergeWithExisting(Annotation existingAnnotation, Annotation... annotations) {
 mergeWithExisting(existingAnnotation, Arrays.asList(annotations));
}
origin: dstl/baleen

protected UimaSupport createSupport(String pipelineName, UimaContext context) {
 return new UimaSupport(
   pipelineName,
   this.getClass(),
   history,
   monitor,
   UimaUtils.isMergeDistinctEntities(context));
}
origin: uk.gov.dstl.baleen/baleen-uima

/**
 * Add a new annotation, which is merged from the old annotations, removing the old annotations.
 *
 * @param newAnnotation The annotation which is to be added to the document as the merged result
 *     of the old annotations
 * @param annotations Annotation(s) which have been merged and should be removed
 */
public void mergeWithNew(Annotation newAnnotation, Annotation... annotations) {
 mergeWithNew(newAnnotation, Arrays.asList(annotations));
}
origin: dstl/baleen

@Test
public void testGetRelations() {
 UimaSupport support = new UimaSupport(PIPELINE, UimaSupportTest.class, history, monitor, false);
 r2.addToIndexes();
 List<Relation> relations = new ArrayList<>(support.getRelations(p1));
 relations = new ArrayList<>(support.getRelations(p2));
 assertEquals(r2, relations.get(1));
 relations = new ArrayList<>(support.getRelations(p3));
origin: dstl/baleen

@Test
public void testMergeWithRelation() {
 UimaSupport support = new UimaSupport(PIPELINE, UimaSupportTest.class, history, monitor, false);
 r.addToIndexes();
 support.mergeWithExisting(p1, p2);
origin: dstl/baleen

/**
 * Remove an annotation to the JCas index, notifying UimaMonitor of the fact we have done so.
 *
 * <p>Relations that refer to the given annotation will also be removed.
 *
 * @param annot Annotation(s) to remove
 */
public void remove(Collection<? extends Annotation> annotations) {
 for (Annotation annot : annotations) {
  if (annot instanceof Recordable) {
   try {
    addToHistory(
      annot.getCAS().getJCas(), HistoryEvents.createAdded((Recordable) annot, referrer));
   } catch (CASException e) {
    monitor.error("Unable to add to history on remove", e);
   }
  }
  if (annot instanceof Entity) {
   for (Relation r : getRelations((Entity) annot)) {
    monitor.entityRemoved(r.getType().getName());
    r.removeFromIndexes();
   }
  }
  monitor.entityRemoved(annot.getType().getName());
  annot.removeFromIndexes();
 }
}
origin: dstl/baleen

final DocumentAnnotation da = UimaSupport.getDocumentAnnotation(jCas);
da.setTimestamp(System.currentTimeMillis());
da.setDocType("re3d");
   a.setConfidence(e.getConfidence());
   getSupport().add(a);
   a.setSource(source.get());
   a.setTarget(target.get());
   getSupport().add(a);
origin: dstl/baleen

@Test
public void testMergeWithDontMergeDifferentReferent() {
 UimaSupport support = new UimaSupport(PIPELINE, UimaSupportTest.class, history, monitor, false);
 md2.addToIndexes();
 support.mergeWithExisting(locationRT2Again, location, locationRT1, locationRT2);
 support.mergeWithExisting(md2, md);
 assertEquals(md2, mds.get(0));
 assertTrue(support.getDocumentHistory(jCas).getHistory(locationRT1.getInternalId()).isEmpty());
 assertFalse(
   support.getDocumentHistory(jCas).getHistory(locationRT2Again.getInternalId()).isEmpty());
uk.gov.dstl.baleen.uimaUimaSupport

Javadoc

A support class for Uima within Baleen.

This is used to keep common functions for manipulating Baleen entities and annotations together to avoid code duplication. It provides helpers to accessing and creating entities, and standardises history.

Users of Baleen do not need to create this object, as it is typically access through BaleenAnnotator, BaleenConsumer, etc and will be preconfigured.

Most used methods

  • getDocumentAnnotation
    Return the document annotation.
  • add
    Add an annotation to the JCas index, notifying UimaMonitor of the fact we have done so
  • getDocumentHistory
    Get (or create) the history associated with the document.
  • <init>
    New instance.
  • getRelations
    Get relations that have a given entity as either the source or the target
  • mergeWithExisting
    Merge an existing annotation with old annotations, removing the old annotations.
  • mergeWithNew
    Add a new annotation, which is merged from the old annotations, removing the old annotations.
  • remove
    Remove an annotation to the JCas index, notifying UimaMonitor of the fact we have done so.Relations
  • addMergeToHistory
  • addToHistory
    Adds a event to the history for this jcas document.
  • getPipelineName
    Get the name of the pipeline to which this belongs.
  • isSameTarget
  • getPipelineName,
  • isSameTarget,
  • mergeEntities,
  • mergeWithExistingNoCoref

Popular in Java

  • Start an intent from android
  • getExternalFilesDir (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • setRequestProperty (URLConnection)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • JOptionPane (javax.swing)
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now