/** * @generated * @param jcas JCas to which this Feature Structure belongs * @param begin offset to the begin spot in the SofA * @param end offset to the end spot in the SofA */ public Entity(JCas jcas, int begin, int end) { super(jcas); setBegin(begin); setEnd(end); readObject(); }
/** * @generated * @param jcas JCas to which this Feature Structure belongs * @param begin offset to the begin spot in the SofA * @param end offset to the end spot in the SofA */ public Entity(JCas jcas, int begin, int end) { super(jcas); setBegin(begin); setEnd(end); readObject(); }
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; }
/** * Copy entity. * * @param jCas the j cas * @param begin the begin * @param end the end * @param entity the entity * @return the entity */ public static Entity copyEntity(JCas jCas, int begin, int end, Entity entity) { // TODO: This could be better, but would suggest if better is need try { final Entity instance = entity.getClass().getConstructor(JCas.class).newInstance(jCas); instance.setBegin(begin); instance.setEnd(end); instance.setReferent(entity.getReferent()); instance.setValue(entity.getValue()); return instance; } catch (final Exception e) { LOGGER.warn("Unable to copy entity", e); return null; } }
/** * Copy entity. * * @param jCas the j cas * @param begin the begin * @param end the end * @param entity the entity * @return the entity */ public static Entity copyEntity(JCas jCas, int begin, int end, Entity entity) { // TODO: This could be better, but would suggest if better is need try { final Entity instance = entity.getClass().getConstructor(JCas.class).newInstance(jCas); instance.setBegin(begin); instance.setEnd(end); instance.setReferent(entity.getReferent()); instance.setValue(entity.getValue()); return instance; } catch (final Exception e) { LOGGER.warn("Unable to copy entity", e); return null; } }
@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; }
a.setBegin(e.getBegin()); a.setEnd(e.getEnd()); a.setValue(e.getValue());
@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); }
a.setBegin(e.getBegin()); a.setEnd(e.getEnd()); a.setValue(e.getValue());
@Test public void testOverlaps() { final Entity a = new Entity(jCas); a.setBegin(0); a.setEnd(10); final Entity b = new Entity(jCas); b.setBegin(8); b.setEnd(15); final Entity c = new Entity(jCas); c.setBegin(20); c.setEnd(30); assertTrue(ComparableEntitySpanUtils.overlaps(a, b)); assertTrue(ComparableEntitySpanUtils.overlaps(b, a)); assertFalse(ComparableEntitySpanUtils.overlaps(a, c)); assertFalse(ComparableEntitySpanUtils.overlaps(c, a)); } }
@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)); }
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(); }