/** * 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; } }
@SafeVarargs public static <T extends Entity> ReferenceTarget createReferenceTarget(JCas jCas, T... entities) { ReferenceTarget rt = new ReferenceTarget(jCas); rt.addToIndexes(); Arrays.stream(entities).forEach(e -> e.setReferent(rt)); return rt; }
private void setLinking(JCas jCas, EntityInformation<T> entityInformation, String linking) { removeFromJCasIndex(entityInformation.getReferenceTarget()); ReferenceTarget referenceTarget = new ReferenceTarget(jCas); referenceTarget.setLinking(linking); for (Entity e : entityInformation.getMentions()) { e.setReferent(referenceTarget); } addToJCasIndex(referenceTarget); addToJCasIndex(entityInformation.getMentions()); }
private void setLinking(JCas jCas, EntityInformation<T> entityInformation, String linking) { removeFromJCasIndex(entityInformation.getReferenceTarget()); ReferenceTarget referenceTarget = new ReferenceTarget(jCas); referenceTarget.setLinking(linking); for (Entity e : entityInformation.getMentions()) { e.setReferent(referenceTarget); } addToJCasIndex(referenceTarget); addToJCasIndex(entityInformation.getMentions()); }
e1.setReferent(rt); e1.addToIndexes(); e1a.setReferent(rt); e1a.addToIndexes();