private List<String> getEntityIds(FSArray entityArray) { List<String> entities = new ArrayList<>(); for (int x = 0; x < entityArray.size(); x++) { FeatureStructure featureStructure = entityArray.get(x); if (featureStructure instanceof Entity) { Entity ent = (Entity) featureStructure; entities.add(ent.getExternalId()); } } return entities; }
private String generateSpanStart(Entity e) { String value = e.getValue() == null ? "" : e.getValue().replaceAll("\"", "'"); String referent = e.getReferent() == null ? "" : Long.toString(e.getReferent().getInternalId()); return String.format( "<span class=\"baleen %s\" id=\"%s\" value=\"%s\" data-referent=\"%s\">", e.getClass().getSimpleName(), e.getExternalId(), value, referent); }
/** * Convert from an entity to a map. * * @param entity the entity to convert * @return a map containing the entity's fields (and history is required) */ public Map<String, Object> convertEntity(Entity entity) { Map<String, Object> map = new IgnoreEmptyKeyMapDecorator<>(Maps.newHashMap()); convertFeatures(map, entity); if (outputHistory && documentHistory != null) { convertHistory(map, entity); } map.put(fields.getExternalId(), entity.getExternalId()); return map; }
/** * Get a usable unique uid for the relation based on the properties, source and target. * * @param relation the relation to identify * @return hash * @throws BaleenException */ public static String getExternalId(Relation relation) { String[] ids = { relation.getExternalId(), relation.getSource().getExternalId(), relation.getTarget().getExternalId() }; try { return IdentityUtils.hashStrings(ids); } catch (BaleenException e) { return fallbackToUUID(e); } }
private void processCoreferencedEntities(Integer docKey, List<Entity> entities) throws SQLException { Set<String> values = new HashSet<>(); Set<String> externalIds = new HashSet<>(); Set<String> geoJsons = new HashSet<>(); Class<? extends Entity> type = null; for (Entity e : entities) { values.add(e.getValue()); externalIds.add(e.getExternalId()); if (e instanceof Location) { Location l = (Location) e; try { geoJsons.add(addCrsToGeoJSON(l.getGeoJson())); } catch (BaleenException ex) { getMonitor().warn("Unable to add CRS to GeoJSON", ex); } } type = getSuperclass(type, e.getClass()); } if (type == null) { // No entities processed return; } Integer entityKey = executeEntityInsert(docKey, values, externalIds, type.getName()); if (entityKey != null) { for (String geoJson : geoJsons) { executeEntityGeoInsert(entityKey, geoJson); } } }
list.add(e.getExternalId());
final BaleenMention mention = new BaleenMention(); final String baleenExternalId = e.getExternalId(); final String externalId = idGenerator.generateForExternalId(baleenExternalId);
final String sourceId = idGenerator.generateForExternalId(source.getExternalId()); br.setSource(mentions.get(sourceId)); final String targetId = idGenerator.generateForExternalId(target.getExternalId()); br.setTarget(mentions.get(targetId));
.append("entityId", entity.getExternalId()) .append(FIELD_TYPE, entity.getType().getShortName()) .append(FIELD_SUBTYPE, entity.getSubType())
.append(FIELD_SENTENCE, sentence) .append(FIELD_DOCUMENT_ID, documentId) .append(FIELD_SOURCE, r.getSource().getExternalId()) .append(FIELD_TARGET, r.getTarget().getExternalId()) .append(FIELD_BEGIN, r.getBegin()) .append(FIELD_END, r.getEnd())
addProperty(vReference, PROPERTY_EXTERNALID, e.getExternalId()); addProperty(vReference, PROPERTY_BEGIN, e.getBegin()); addProperty(vReference, PROPERTY_END, e.getEnd()); vReference.addEdge(LABEL_EDGE_REFERENCE, vEntity); refToEntity.put(e.getExternalId(), vEntity); Vertex vSource = refToEntity.get(r.getSource().getExternalId()); Vertex vTarget = refToEntity.get(r.getTarget().getExternalId());
map.put(ConsumerUtils.toCamelCase(f.getShortName()), ((Entity) ent).getExternalId()); } else { getMonitor().trace("Unable to persist feature {}", f.getShortName());