/** Creates a new relation between entities and/or sentiment features. It assigns an appropriate ID to it. The relation is added to the document. * @param from source of the relation * @param to target of the relation * @return a new relation */ public Relation newRelation(Relational from, Relational to) { String newId = idManager.getNextId(AnnotationType.RELATION); Relation newRelation = new Relation(newId, from, to); annotationContainer.add(newRelation, Layer.RELATIONS, AnnotationType.RELATION); return newRelation; }
public String getStr() { String str = "(" + this.from.getStr() + ", " + this.to.getStr() + ")"; if (this.hasConfidence()) { str += " [" + this.getConfidence() + "]"; } return str; }
/** * Adds a relation to the container */ void add(Relation relation) { relations.add(relation); /* Index by 'from' and 'to' terms */ if (relation.getFrom() != null) { String rId = relation.getFrom().getId(); indexAnnotation(relation, rId, relationsIndexedByRelational); } if (relation.getTo() != null) { String rId = relation.getTo().getId(); indexAnnotation(relation, rId, relationsIndexedByRelational); } }
Element relationsElem = new Element("relations"); for (Relation relation : relations) { Comment comment = new Comment(relation.getStr()); relationsElem.addContent(comment); Element relationElem = new Element("relation"); relationElem.setAttribute("id", relation.getId()); relationElem.setAttribute("from", relation.getFrom().getId()); relationElem.setAttribute("to", relation.getTo().getId()); if (relation.hasConfidence()) { relationElem.setAttribute("confidence", String.valueOf(relation.getConfidence()));
Relation(Relation relation, HashMap<String, Relational> relational) { super(relation.getId()); this.id = relation.getId(); if (relation.from != null) { this.from = relational.get(relation.from.getId()); if (this.from == null) { throw new IllegalStateException("Couldn't find relational " + relation.from.getId() + " when copying " + relation.getId()); } } if (relation.to != null) { this.to = relational.get(relation.to.getId()); if (this.to == null) { throw new IllegalStateException("Couldn't find relational " + relation.to.getId() + " when copying " + relation.getId()); } } this.confidence = relation.confidence; }
newRelation.setConfidence(confidence);
public String insertRelation(Relation relation) { String newId = idManager.relations.getNext(); relation.setId(newId); annotationContainer.add(relation); return newId; }
Element relationsElem = new Element("relations"); for (Relation relation : relations) { Comment comment = new Comment(StringEscapeUtils.escapeXml11(relation.getStr())); relationsElem.addContent(comment); Element relationElem = new Element("relation"); relationElem.setAttribute("id", relation.getId()); relationElem.setAttribute("from", relation.getFrom().getId()); relationElem.setAttribute("to", relation.getTo().getId()); if (relation.hasConfidence()) { relationElem.setAttribute("confidence", String.valueOf(relation.getConfidence()));
Relation(Relation relation, HashMap<String, Relational> relational) { this.id = id; if (relation.from != null) { this.from = relational.get(relation.from.getId()); if (this.from == null) { throw new IllegalStateException("Couldn't find relational " + relation.from.getId() + " when copying " + relation.getId()); } } if (relation.to != null) { this.to = relational.get(relation.to.getId()); if (this.to == null) { throw new IllegalStateException("Couldn't find relational " + relation.to.getId() + " when copying " + relation.getId()); } } this.confidence = relation.confidence; }
newRelation.setConfidence(confidence);
public String getStr() { String str = "(" + this.from.getStr() + ", " + this.to.getStr() + ")"; if (this.hasConfidence()) { str += " [" + this.getConfidence() + "]"; } return str; } }
/** Creates a new relation between entities and/or sentiment features. It receives its ID as an argument. The relation is added to the document. * @param id the ID of the relation * @param from source of the relation * @param to target of the relation * @return a new relation */ public Relation newRelation(String id, Relational from, Relational to) { idManager.updateCounter(AnnotationType.RELATION, id); Relation newRelation = new Relation(id, from, to); annotationContainer.add(newRelation, Layer.RELATIONS, AnnotationType.RELATION); return newRelation; }
/** * Creates a new relation between entities and/or sentiment features. It assigns an appropriate ID to it. The relation is added to the document. * * @param from source of the relation * @param to target of the relation * @return a new relation */ public Relation newRelation(Relational from, Relational to) { String newId = idManager.relations.getNext(); Relation newRelation = new Relation(newId, from, to); annotationContainer.add(newRelation); return newRelation; }
/** * Creates a new relation between entities and/or sentiment features. It receives its ID as an argument. The relation is added to the document. * * @param id the ID of the relation * @param from source of the relation * @param to target of the relation * @return a new relation */ public Relation newRelation(String id, Relational from, Relational to) { idManager.relations.update(id); Relation newRelation = new Relation(id, from, to); annotationContainer.add(newRelation); return newRelation; }
Relation relationCopy = new Relation(relation, copiedRelationals); kaf.insertRelation(relationCopy);
Relation relationCopy = new Relation(relation, copiedRelationals); this.insertRelation(relationCopy);