MCPcopy Create free account
hub / github.com/GateNLP/gate-core / addRelation

Method addRelation

src/main/java/gate/relations/RelationSet.java:176–203  ·  view source on GitHub ↗

Creates a new Relation and adds it to this set. Uses the default relation implementation at SimpleRelation. @param type the type for the new relation. @param members the annotation IDs for the annotations that are members in this relation. @return the newly created {@link R

(String type, int... members)

Source from the content-addressed store, hash-verified

174 * @return the newly created {@link Relation} instance.
175 */
176 public Relation addRelation(String type, int... members)
177 throws IllegalArgumentException {
178
179 if(members.length < 2)
180 throw new IllegalArgumentException(
181 "A relation needs to have atleast two members");
182
183 for(int member : members) {
184 if(!indexById.containsKey(member) && annSet.get(member) == null)
185 throw new IllegalArgumentException(
186 "Member must be from within this annotation set");
187 }
188
189 if(type == null || type.trim().equals(""))
190 throw new IllegalArgumentException("A relation must have a type");
191
192 // now we have sanity checked the params create the relation
193 Relation rel =
194 new SimpleRelation(
195 ((DocumentImpl)annSet.getDocument()).getNextAnnotationId(),
196 type, members);
197
198 // add the relation to the set
199 add(rel);
200
201 // return the relation to the calling method
202 return rel;
203 }
204
205 /**
206 * Adds an externally-created {@link Relation} instance.

Callers

nothing calls this directly

Calls 6

addMethod · 0.95
getNextAnnotationIdMethod · 0.80
getMethod · 0.65
equalsMethod · 0.65
getDocumentMethod · 0.65
containsKeyMethod · 0.45

Tested by

no test coverage detected