Java Code Examples for org.apache.uima.jcas.tcas.DocumentAnnotation#setDocumentCaveats()

The following examples show how to use org.apache.uima.jcas.tcas.DocumentAnnotation#setDocumentCaveats() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ElasticsearchTestBase.java    From baleen with Apache License 2.0 6 votes vote down vote up
protected long createNoEntitiesDocument() {
  jCas.reset();
  jCas.setDocumentText("Hello World");
  jCas.setDocumentLanguage("en");

  long timestamp = System.currentTimeMillis();

  DocumentAnnotation da = getDocumentAnnotation(jCas);
  da.setTimestamp(timestamp);
  da.setSourceUri("test/no_entities");
  da.setDocType("test");
  da.setDocumentClassification("OFFICIAL");
  da.setDocumentCaveats(
      UimaTypesUtils.toArray(jCas, Arrays.asList(new String[] {"TEST_A", "TEST_B"})));
  da.setDocumentReleasability(
      UimaTypesUtils.toArray(jCas, Arrays.asList(new String[] {"ENG", "SCO", "WAL"})));

  return timestamp;
}
 
Example 2
Source File: JCasDeserialiser.java    From baleen with Apache License 2.0 5 votes vote down vote up
private void processDocumentAnnotation(
    final JCas jCas, final DocumentAnnotation da, final Map<String, Object> map) {
  da.setDocType((String) map.getOrDefault(JsonJCas.DA_DOCUMENT_TYPE, ""));
  da.setDocumentClassification((String) map.getOrDefault(JsonJCas.DA_CLASSIFICATION, ""));
  da.setLanguage((String) map.getOrDefault(JsonJCas.DA_LANGUAGE, ""));
  da.setSourceUri((String) map.getOrDefault(JsonJCas.DA_SOURCE_URI, ""));
  da.setTimestamp(((Number) map.getOrDefault(JsonJCas.DA_TIMESTAMP, 0)).longValue());

  da.setDocumentCaveats(
      UimaTypesUtils.toArray(
          jCas, (Collection<String>) map.getOrDefault(JsonJCas.DA_CAVEATS, null)));
  da.setDocumentReleasability(
      UimaTypesUtils.toArray(
          jCas, (Collection<String>) map.getOrDefault(JsonJCas.DA_RELEASABILITY, null)));
}
 
Example 3
Source File: GremlinConsumerTest.java    From baleen with Apache License 2.0 5 votes vote down vote up
@Test
public void test() throws Exception {
  jCas.setDocumentText("Hello James! Is your e-mail address [email protected]? 'No', said James.");

  DocumentAnnotation da = getDocumentAnnotation(jCas);
  da.setDocType("test");
  da.setSourceUri("http://www.example.com/hello.txt");

  StringArray sa = new StringArray(jCas, 2);
  sa.set(0, "UK");
  sa.set(1, "US");
  da.setDocumentCaveats(sa);

  ReferenceTarget rt = new ReferenceTarget(jCas);
  rt.addToIndexes();

  Entity e1 = new Person(jCas, 6, 11);
  e1.setValue("James");
  e1.setReferent(rt);
  e1.addToIndexes();

  Entity e1a = new Person(jCas, 60, 65);
  e1a.setValue("James");
  e1a.setReferent(rt);
  e1a.addToIndexes();

  Entity e2 = new CommsIdentifier(jCas, 36, 47);
  e2.setValue("[email protected]");
  e2.addToIndexes();

  processJCas(GremlinConsumer.PARAM_GRAPH_CONFIG, tmpConfig.getPath());

  // TODO: Write some proper tests that actually check something
}
 
Example 4
Source File: JCasTestGraphUtil.java    From baleen with Apache License 2.0 4 votes vote down vote up
public static void populateJcas(final JCas jCas) {

    jCas.setDocumentText(CONTENT);
    final DocumentAnnotation da = (DocumentAnnotation) jCas.getDocumentAnnotationFs();
    da.setDocumentClassification("CLASS");
    da.setDocType("MANUAL");
    da.setSourceUri("http://test.com");
    da.setLanguage("en");
    da.setTimestamp(new Date().getTime());
    da.setDocumentCaveats(new StringArray(jCas, 2));
    da.setDocumentCaveats(0, "GITHUB");
    da.setDocumentCaveats(1, "CAVEAT");

    final Metadata m1 = new Metadata(jCas);
    m1.setKey("test");
    m1.setValue("1");
    m1.addToIndexes(jCas);

    final Metadata m2 = new Metadata(jCas);
    m2.setKey("test");
    m2.setValue("2");
    m2.addToIndexes(jCas);

    final PublishedId pId = new PublishedId(jCas);
    pId.setPublishedIdType("test");
    pId.setValue("12");
    pId.addToIndexes(jCas);

    ReferenceTarget target = new ReferenceTarget(jCas);
    target.setLinking("testLinking");
    target.addToIndexes(jCas);

    final Person js = new Person(jCas);
    js.setBegin(25);
    js.setEnd(35);
    js.setGender("Male");
    js.setValue("John Smith");
    js.setConfidence(0.9d);
    js.setReferent(target);
    js.addToIndexes(jCas);

    final Person jd = new Person(jCas);
    jd.setBegin(50);
    jd.setEnd(58);
    jd.setGender("Female");
    jd.setValue("Jane Doe");
    jd.setConfidence(0.8d);
    jd.addToIndexes(jCas);

    final Person he = new Person(jCas);
    he.setBegin(60);
    he.setEnd(62);
    he.setGender("Male");
    he.setValue("He");
    he.setConfidence(0.9d);
    he.setReferent(target);
    he.addToIndexes(jCas);

    final Location l = new Location(jCas);
    l.setBegin(72);
    l.setEnd(87);
    l.setGeoJson(GEO_JSON);
    l.setValue("Dinagat Islands");
    l.setConfidence(0.9d);
    l.addToIndexes(jCas);

    final Relation related = new Relation(jCas);
    related.setBegin(36);
    related.setEnd(49);
    related.setValue("is related to");
    related.setRelationshipType(RELATED_TYPE);
    related.setSource(js);
    related.setTarget(jd);
    related.addToIndexes(jCas);

    final Relation lives = new Relation(jCas);
    lives.setBegin(63);
    lives.setEnd(71);
    lives.setValue("lives at");
    lives.setRelationshipType(LIVES_TYPE);
    lives.setSource(js);
    lives.setTarget(l);
    lives.addToIndexes(jCas);

    final Event event = new Event(jCas);
    event.setBegin(0);
    event.setEnd(10);
    event.setValue("test event");
    event.setEventType(new StringArray(jCas, 1));
    event.setEventType(0, "MEETING");
    event.setEntities(new FSArray(jCas, 2));
    event.setEntities(0, js);
    event.setEntities(1, jd);
    event.setArguments(new StringArray(jCas, 2));
    event.setArguments(0, "argument");
    event.setArguments(1, "Other");
    event.addToIndexes(jCas);
  }
 
Example 5
Source File: MongoTest.java    From baleen with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testNoEntities() throws Exception {
  jCas.setDocumentText(TEXT);
  jCas.setDocumentLanguage("en");

  long timestamp = System.currentTimeMillis();

  DocumentAnnotation da = getDocumentAnnotation(jCas);
  da.setTimestamp(timestamp);
  da.setSourceUri("test/no_entities");
  da.setDocType("test");
  da.setDocumentClassification("OFFICIAL");
  da.setDocumentCaveats(
      UimaTypesUtils.toArray(jCas, Arrays.asList(new String[] {"TEST_A", "TEST_B"})));
  da.setDocumentReleasability(
      UimaTypesUtils.toArray(jCas, Arrays.asList(new String[] {"ENG", "SCO", "WAL"})));

  ae.process(jCas);

  assertEquals(1, documents.count());
  Document result = documents.find().first();

  assertEquals(TEXT, result.get(Mongo.FIELD_CONTENT));
  assertEquals(
      "en", ((Document) result.get(Mongo.FIELD_DOCUMENT)).get(Mongo.FIELD_DOCUMENT_LANGUAGE));

  assertEquals(
      new Date(timestamp),
      ((Document) result.get(Mongo.FIELD_DOCUMENT)).get(Mongo.FIELD_DOCUMENT_TIMESTAMP));
  assertEquals(
      "test/no_entities",
      ((Document) result.get(Mongo.FIELD_DOCUMENT)).get(Mongo.FIELD_DOCUMENT_SOURCE));

  assertEquals(
      "test", ((Document) result.get(Mongo.FIELD_DOCUMENT)).get(Mongo.FIELD_DOCUMENT_TYPE));

  assertEquals(
      "OFFICIAL",
      ((Document) result.get(Mongo.FIELD_DOCUMENT)).get(Mongo.FIELD_DOCUMENT_CLASSIFICATION));
  assertArrayEquals(
      new String[] {"TEST_A", "TEST_B"},
      ((Collection<String>)
              ((Document) result.get(Mongo.FIELD_DOCUMENT)).get(Mongo.FIELD_DOCUMENT_CAVEATS))
          .toArray());
  assertArrayEquals(
      new String[] {"ENG", "SCO", "WAL"},
      ((Collection<String>)
              ((Document) result.get(Mongo.FIELD_DOCUMENT))
                  .get(Mongo.FIELD_DOCUMENT_RELEASABILITY))
          .toArray());

  assertEquals(getDocumentAnnotation(jCas).getHash(), result.get(fields.getExternalId()));
}