/** Creates a new property. It receives it's ID as an argument. The property is added to the document. * @param id the ID of the property. * @param lemma the lemma of the property. * @param references different mentions (list of targets) to the same property. * @return a new coreference. */ public Feature newProperty(String id, String lemma, List<Span<Term>> references) { idManager.updateCounter(AnnotationType.PROPERTY, id); Feature newProperty = new Feature(id, lemma, references); annotationContainer.add(newProperty, Layer.PROPERTIES, AnnotationType.PROPERTY); return newProperty; }
public String getStr() { return getSpanStr(this.getSpans().get(0)); }
/** * Adds a feature to the container. It checks if it is a property or a category. */ void add(Feature feature) { if (feature.isAProperty()) { properties.add(feature); /* Index by terms */ for (Term term : feature.getTerms()) { indexAnnotation(feature, term.getId(), propertiesIndexedByTerm); } //this.indexBySent(feature, feature.getSpans().get(0).getTargets().get(0).getSent(), this.propertiesIndexedBySent); } else { categories.add(feature); /* Index by terms */ for (Term term : feature.getTerms()) { indexAnnotation(feature, term.getId(), categoriesIndexedByTerm); } //this.indexBySent(feature, feature.getSpans().get(0).getTargets().get(0).getSent(), this.categoriesIndexedBySent); } }
for (Feature property : properties) { Element propertyElem = new Element("property"); propertyElem.setAttribute("id", property.getId()); propertyElem.setAttribute("lemma", property.getLemma()); List<Span<Term>> references = property.getSpans(); Element referencesElem = new Element("references"); for (Span<Term> span : references) { Comment spanComment = new Comment(property.getSpanStr(span)); referencesElem.addContent(spanComment); Element spanElem = new Element("span"); for (Feature category : categories) { Element categoryElem = new Element("category"); categoryElem.setAttribute("id", category.getId()); categoryElem.setAttribute("lemma", category.getLemma()); List<Span<Term>> references = category.getSpans(); Element referencesElem = new Element("references"); for (Span<Term> span : references) { Comment spanComment = new Comment(category.getSpanStr(span)); referencesElem.addContent(spanComment); Element spanElem = new Element("span");
this.lemma = feature.lemma; String id = feature.getId(); this.references = new ArrayList<Span<Term>>(); for (Span<Term> span : feature.getSpans()) { for (ExternalRef externalRef : feature.getExternalRefs()) { this.externalReferences.add(new ExternalRef(externalRef));
if (externalReferencesElems.size() > 0) { List<ExternalRef> externalRefs = getExternalReferences(externalReferencesElems.get(0), kaf); newProperty.addExternalRefs(externalRefs); relationalIndex.put(newProperty.getId(), newProperty); if (externalReferencesElems.size() > 0) { List<ExternalRef> externalRefs = getExternalReferences(externalReferencesElems.get(0), kaf); newCategory.addExternalRefs(externalRefs); relationalIndex.put(newCategory.getId(), newCategory);
Map<AnnotationType, List<Annotation>> getReferencedAnnotations() { Map<AnnotationType, List<Annotation>> referenced = new HashMap<AnnotationType, List<Annotation>>(); List<Annotation> terms = new ArrayList<Annotation>(); for (Span<Term> span : this.getSpans()) { terms.addAll((List<Annotation>)(List<?>) span.getTargets()); } referenced.put(AnnotationType.TERM, terms); return referenced; }
Map<AnnotationType, List<Annotation>> getReferencedAnnotations() { Map<AnnotationType, List<Annotation>> referenced = new HashMap<AnnotationType, List<Annotation>>(); List<Annotation> entities = new ArrayList<Annotation>(); List<Annotation> properties = new ArrayList<Annotation>(); List<Annotation> categories = new ArrayList<Annotation>(); if (this.from instanceof Entity) entities.add((Annotation)this.from); else if (((Feature)this.from).isAProperty()) properties.add((Annotation)this.from); else categories.add((Annotation)this.from); if (this.to instanceof Entity) entities.add((Annotation)this.to); else if (((Feature)this.to).isAProperty()) properties.add((Annotation)this.to); else categories.add((Annotation)this.to); referenced.put(AnnotationType.ENTITY, (List<Annotation>)(List<?>) entities); referenced.put(AnnotationType.PROPERTY, (List<Annotation>)(List<?>) properties); referenced.put(AnnotationType.CATEGORY, (List<Annotation>)(List<?>) categories); return referenced; }
public String insertCategory(Feature category) { String newId = idManager.categories.getNext(); category.setId(newId); annotationContainer.add(category); return newId; }
for (Feature property : properties) { Element propertyElem = new Element("property"); propertyElem.setAttribute("id", property.getId()); propertyElem.setAttribute("lemma", property.getLemma()); List<Span<Term>> references = property.getSpans(); Element referencesElem = new Element("references"); for (Span<Term> span : references) { Comment spanComment = new Comment(StringEscapeUtils.escapeXml11(property.getSpanStr(span))); referencesElem.addContent(spanComment); Element spanElem = new Element("span"); for (Feature category : categories) { Element categoryElem = new Element("category"); categoryElem.setAttribute("id", category.getId()); categoryElem.setAttribute("lemma", category.getLemma()); List<Span<Term>> references = category.getSpans(); Element referencesElem = new Element("references"); for (Span<Term> span : references) { Comment spanComment = new Comment(StringEscapeUtils.escapeXml11(category.getSpanStr(span))); referencesElem.addContent(spanComment); Element spanElem = new Element("span");
this.lemma = feature.lemma; String id = feature.getId(); this.references = new ArrayList<Span<Term>>(); for (Span<Term> span : feature.getSpans()) { for (ExternalRef externalRef : feature.getExternalRefs()) { this.externalReferences.add(new ExternalRef(externalRef));
if (externalReferencesElems.size() > 0) { List<ExternalRef> externalRefs = getExternalReferences(externalReferencesElems.get(0), kaf); newProperty.addExternalRefs(externalRefs); relationalIndex.put(newProperty.getId(), newProperty); if (externalReferencesElems.size() > 0) { List<ExternalRef> externalRefs = getExternalReferences(externalReferencesElems.get(0), kaf); newCategory.addExternalRefs(externalRefs); relationalIndex.put(newCategory.getId(), newCategory);
public String insertProperty(Feature property) { String newId = idManager.properties.getNext(); property.setId(newId); annotationContainer.add(property); return newId; }
/** Creates a new category. It receives it's ID as an argument. The category is added to the document. * @param id the ID of the category. * @param lemma the lemma of the category. * @param references different mentions (list of targets) to the same category. * @return a new coreference. */ public Feature newCategory(String id, String lemma, List<Span<Term>> references) { idManager.updateCounter(AnnotationType.CATEGORY, id); Feature newCategory = new Feature(id, lemma, references); annotationContainer.add(newCategory, Layer.CATEGORIES, AnnotationType.CATEGORY); return newCategory; }
public String getStr() { return getSpanStr(this.getSpans().get(0)); }
/** Creates a new property. It assigns an appropriate ID to it. The property is added to the document. * @param lemma the lemma of the property. * @param references different mentions (list of targets) to the same property. * @return a new coreference. */ public Feature newProperty(String lemma, List<Span<Term>> references) { String newId = idManager.getNextId(AnnotationType.PROPERTY); Feature newProperty = new Feature(newId, lemma, references); annotationContainer.add(newProperty, Layer.PROPERTIES, AnnotationType.PROPERTY); return newProperty; }
/** Creates a new category. It assigns an appropriate ID to it. The category is added to the document. * @param lemma the lemma of the category. * @param references different mentions (list of targets) to the same category. * @return a new coreference. */ public Feature newCategory(String lemma, List<Span<Term>> references) { String newId = idManager.getNextId(AnnotationType.CATEGORY); Feature newCategory = new Feature(newId, lemma, references); annotationContainer.add(newCategory, Layer.CATEGORIES, AnnotationType.CATEGORY); return newCategory; }
/** * Creates a new category. It assigns an appropriate ID to it. The category is added to the document. * * @param lemma the lemma of the category. * @param references different mentions (list of targets) to the same category. * @return a new coreference. */ public Feature newCategory(String lemma, List<Span<Term>> references) { String newId = idManager.categories.getNext(); Feature newCategory = new Feature(newId, lemma, references); annotationContainer.add(newCategory); return newCategory; }