/** * Get relations that have a given entity as either the source or the target * * @param e The given entity * @return Collection of relations that refer to the given Entity */ public Collection<Relation> getRelations(Entity e) { try { JCas jCas = e.getCAS().getJCas(); Collection<Relation> relations = JCasUtil.select(jCas, Relation.class); return relations .stream() .filter(r -> r.getSource() == e || r.getTarget() == e) .collect(Collectors.toList()); } catch (UIMAException ue) { monitor.warn("Unable to get relations from entity", ue); return Collections.emptyList(); } } }
/** * Get relations that have a given entity as either the source or the target * * @param e The given entity * @return Collection of relations that refer to the given Entity */ public Collection<Relation> getRelations(Entity e) { try { JCas jCas = e.getCAS().getJCas(); Collection<Relation> relations = JCasUtil.select(jCas, Relation.class); return relations .stream() .filter(r -> r.getSource() == e || r.getTarget() == e) .collect(Collectors.toList()); } catch (UIMAException ue) { monitor.warn("Unable to get relations from entity", ue); return Collections.emptyList(); } } }