LinkedEntity(LinkedEntity linkedEntity, HashMap<String, WF> WFs) { this.linkedEntityId = linkedEntity.linkedEntityId; this.resource = linkedEntity.resource; this.reference = linkedEntity.reference; this.confidence = linkedEntity.confidence; String id = linkedEntity.getId(); this.mentions = linkedEntity.getWFs(); }
/** * Creates a LinkedEntity object and add it to the document, using the supplied ID. * * @param id the entity ID * @param term the Term of the coreference * @return a new factuality */ public LinkedEntity newLinkedEntity(String id, Span<WF> span) { LinkedEntity linkedEntity = new LinkedEntity(id, span); annotationContainer.add(linkedEntity); return linkedEntity; }
Map<AnnotationType, List<Annotation>> getReferencedAnnotations() { Map<AnnotationType, List<Annotation>> referenced = new HashMap<AnnotationType, List<Annotation>>(); referenced.put(AnnotationType.WF, (List<Annotation>)(List<?>) this.getSpan().getTargets()); return referenced; }
for (LinkedEntity e : linkedEntities) { Element lEnt = new Element("linkedEntity"); lEnt.setAttribute("id", e.getId()); lEnt.setAttribute("resource", e.getResource()); lEnt.setAttribute("reference", e.getReference()); lEnt.setAttribute("confidence", Double.toString(e.getConfidence())); lEnt.setAttribute("spotted", e.isSpotted().toString()); Comment spanComment = new Comment(e.getSpanStr()); lEnt.addContent(spanComment); Element spanElem = new Element("span"); for (WF target : e.getWFs().getTargets()) { Element targetElem = new Element("target"); targetElem.setAttribute("id", target.getId()); if (e.getTypes().size() > 0) { Element typesElement = new Element("types"); for (String category : e.getTypes().keySet()) { for (String type : e.getTypes().get(category)) { Element typeElement = new Element("type"); typeElement.setAttribute("source", category);
for (LinkedEntity e : linkedEntities) { Element lEnt = new Element("linkedEntity"); lEnt.setAttribute("id", e.getId()); lEnt.setAttribute("resource", e.getResource()); lEnt.setAttribute("reference", e.getReference()); lEnt.setAttribute("confidence", Double.toString(e.getConfidence())); Comment spanComment = new Comment(StringEscapeUtils.escapeXml11(e.getSpanStr())); lEnt.addContent(spanComment); Element spanElem = new Element("span"); for (WF target : e.getWFs().getTargets()) { Element targetElem = new Element("target"); targetElem.setAttribute("id", target.getId());
final List<Term> terms = document.getTermsByWFs(le.getWFs().getTargets()); final Term head = document.getTermsHead(terms); if (head == null) { final Span<Term> span = KAFDocument.newTermSpan(document.getTermsByWFs(le.getWFs() .getTargets())); boolean overlap = false; if (!accept) { final String textStr = span.getStr().toLowerCase().replaceAll("\\s+", "_"); final String entityStr = new URIImpl(le.getReference()).getLocalName() .toLowerCase(); accept = textStr.equals(entityStr); && NAFUtils.getRef(entityToModify, le.getResource(), le.getReference()) == null) { final ExternalRef ref = document.newExternalRef(le.getResource(), le.getReference()); ref.setConfidence((float) le.getConfidence()); NAFUtils.addRef(entityToModify, ref); LOGGER.debug("Added ref '" + ref + "' to " + NAFUtils.toString(entityToModify)); if (NAFUtils.getRef(predicate, le.getResource(), le.getReference()) == null) { final ExternalRef ref = document.newExternalRef(le.getResource(), le.getReference()); ref.setConfidence((float) le.getConfidence()); NAFUtils.addRef(predicate, ref); LOGGER.debug("Added ref '" + ref + "' to " + NAFUtils.toString(predicate));
e.setResource(getOptAttribute("resource", entityElem)); e.setReference(getOptAttribute("reference", entityElem)); e.setSpotted(spotted != null && spotted.equals("true")); e.setConfidence(Double.parseDouble(confidence)); String category = getAttribute("source", topicElem); String label = getAttribute("label", topicElem); e.addType(category, label);
/** * Adds a linked entity to the container */ void add(LinkedEntity linkedEntity) { linkedEntities.add(linkedEntity); /* Index by terms */ if (linkedEntity.getWFs() != null) { for (WF wf : linkedEntity.getWFs().getTargets()) { indexAnnotation(linkedEntity, wf.getId(), linkedEntitiesIndexedByWF); } } }
LinkedEntity(LinkedEntity linkedEntity, HashMap<String, WF> WFs) { super(linkedEntity.getId()); this.resource = linkedEntity.resource; this.reference = linkedEntity.reference; this.confidence = linkedEntity.confidence; String id = linkedEntity.getId(); this.mentions = linkedEntity.getWFs(); // for (Span<WF> span : linkedEntity.getSpans()) { // List<WF> targets = span.getTargets(); // List<WF> copiedTargets = new ArrayList<WF>(); // for (WF wf : targets) { // WF copiedWF = WFs.get(wf.getId()); // if (copiedWF == null) { // throw new IllegalStateException("Term not found when copying " + id); // } // copiedTargets.add(copiedWF); // } // if (span.hasHead()) { // WF copiedHead = WFs.get(span.getHead().getId()); // this.mentions.add(new Span<WF>(copiedTargets, copiedHead)); // } // else { // this.mentions.add(new Span<WF>(copiedTargets)); // } // } }
/** * Creates a LinkedEntity object and add it to the document * * @param term the Term of the coreference. * @return a new factuality. */ public LinkedEntity newLinkedEntity(Span<WF> span) { String newId = idManager.linkedentities.getNext(); LinkedEntity linkedEntity = new LinkedEntity(newId, span); annotationContainer.add(linkedEntity); return linkedEntity; }