private <T extends Entity> T addToHeaderBlock( final String v, final int offset, final StringBuilder sb, final T annotation) { final int begin = sb.length() + offset; sb.append(v); final int end = sb.length() + offset; sb.append("\n"); annotation.setBegin(begin); annotation.setEnd(end); annotation.setConfidence(1); annotation.setValue(v); annotation.addToIndexes(); return annotation; }
private <T extends Entity> T addToHeaderBlock( final String v, final int offset, final StringBuilder sb, final T annotation) { final int begin = sb.length() + offset; sb.append(v); final int end = sb.length() + offset; sb.append("\n"); annotation.setBegin(begin); annotation.setEnd(end); annotation.setConfidence(1); annotation.setValue(v); annotation.addToIndexes(); return annotation; }
@Test public void testCopyEntity() { final Entity e = new Entity(jCas); e.setBegin(0); e.setBegin(5); e.setValue("value"); e.addToIndexes(); final Entity copyEntity = ComparableEntitySpanUtils.copyEntity(jCas, 10, 20, e); copyEntity.addToIndexes(); final List<Entity> select = new ArrayList<>(JCasUtil.select(jCas, Entity.class)); assertEquals(2, select.size()); assertSame(e, select.get(0)); assertEquals("value", select.get(1).getValue()); assertEquals(10, select.get(1).getBegin()); assertEquals(20, select.get(1).getEnd()); }
public static Entity createEntity(JCas jCas, int begin, int end, String value) { Entity e = new Entity(jCas); e.setBegin(begin); e.setEnd(end); if (value != null) { e.setValue(e.getCoveredText()); } e.addToIndexes(); return e; }
@Test public void testInteger() { Entity e = new Entity(jCas); e.setBegin(5); e.addToIndexes(); Feature f = e.getType().getFeatureByBaseName("begin"); Object o = FeatureUtils.featureToObject(f, e); assertTrue(o instanceof Integer); assertEquals(new Integer(5), (Integer) o); }
@Test public void testLong() { Entity e = new Entity(jCas); e.setInternalId(123456789); e.addToIndexes(); Feature f = e.getType().getFeatureByBaseName("internalId"); Object o = FeatureUtils.featureToObject(f, e); assertTrue(o instanceof Long); assertEquals(new Long(123456789), (Long) o); }
@Test public void testDouble() { Entity e = new Entity(jCas); e.setConfidence(0.5); e.addToIndexes(); Feature f = e.getType().getFeatureByBaseName("confidence"); Object o = FeatureUtils.featureToObject(f, e); assertTrue(o instanceof Double); assertEquals(new Double(0.5), (Double) o); }
fox.setBegin(4); fox.setEnd(7); fox.addToIndexes(jCas); dog.addToIndexes(jCas);
@Test public void testDouble() { Entity e = new Entity(jCas); e.setConfidence(0.5); e.addToIndexes(); Feature feature = e.getType().getFeatureByBaseName("confidence"); NewFeatureUtils.setPrimitive(e, feature, 1.0); assertEquals(1.0, e.getDoubleValue(feature), 0.0); }
@Test public void testFloat() { Entity e = new Entity(jCas); e.setIsNormalised(false); e.addToIndexes(); Feature feature = e.getType().getFeatureByBaseName("isNormalised"); NewFeatureUtils.setPrimitive(e, feature, true); assertTrue(e.getBooleanValue(feature)); }
@Test public void testString() { Entity e = new Entity(jCas); e.setValue("Test Value"); e.addToIndexes(); Feature f = e.getType().getFeatureByBaseName("value"); Object o = FeatureUtils.featureToObject(f, e); assertTrue(o instanceof String); assertEquals("Test Value", (String) o); }
fox.setBegin(4); fox.setEnd(7); fox.addToIndexes(jCas); dog.addToIndexes(jCas);
@Test public void testString() { Entity e = new Entity(jCas); e.setValue("entity"); e.addToIndexes(); Feature feature = e.getType().getFeatureByBaseName("value"); NewFeatureUtils.setPrimitive(e, feature, "newValue"); assertEquals("newValue", e.getStringValue(feature)); }
@Test public void testInteger() { Entity e = new Entity(jCas); e.setBegin(0); e.addToIndexes(); Feature feature = e.getType().getFeatureByBaseName("begin"); NewFeatureUtils.setPrimitive(e, feature, 1); assertEquals(1, e.getIntValue(feature)); }
@Test public void testLong() { Entity e = new Entity(jCas); e.setInternalId(12345); e.addToIndexes(); Feature feature = e.getType().getFeatureByBaseName("internalId"); NewFeatureUtils.setPrimitive(e, feature, 54321); assertEquals(54321, e.getLongValue(feature)); }
e1.setValue("James"); e1.setReferent(rt); e1.addToIndexes(); e1a.addToIndexes(); e2.addToIndexes();
protected void createEntitiesDocument2() { jCas.reset(); jCas.setDocumentText( "Paula went to London on 12th February 2017. In Paris, she met a UID male."); Annotations.createPerson(jCas, 0, 5, "Paula"); Annotations.createLocation(jCas, 47, 53, "Paris", null); Temporal d = Annotations.createTemporal(jCas, 24, 42, ""); d.setConfidence(1.0); Entity e = new Entity(jCas); e.setBegin(14); e.setEnd(20); e.setValue("London"); e.addToIndexes(); }
a.addToIndexes(); final Entity b = new Entity(jCas); b.setValue("b"); b.addToIndexes(); final Entity c = new Entity(jCas); c.setValue("c"); c.addToIndexes();
cow.setBegin(4); cow.setEnd(7); cow.addToIndexes(jCas); moon.addToIndexes(jCas);
cow.setBegin(4); cow.setEnd(7); cow.addToIndexes(jCas); moon.addToIndexes(jCas);