private DocumentRelation( IType relationType, ImmutableSet<RelationMention> provenances, ImmutableSet<DocumentRelationArgument> arguments, ImmutableMap<IType, Float> attributes, float confidence) { this.relationType = checkNotNull(relationType); this.provenances = ImmutableSet.copyOf(provenances); for (final RelationMention arg : provenances) { checkArgument( relationType.equals(arg.getRelationType()), "A document relation's provenance's relation type must match its own, " + "but got argument of type %s for relation of type %s", arg.getRelationType(), relationType); } this.arguments = ImmutableSet.copyOf(arguments); this.attributes = ImmutableMap.copyOf(attributes); // no null check because it's optional this.confidence = confidence; }
/** * @param provenance may not be {@code null}. May differ in relation type from this. * @return */ public Builder addProvenanceFromArgumentTuple(ArgumentTuple provenance) { Optional<RelationMention> relationMention = RelationMention.fromArgumentTuple(provenance); if (relationMention.isPresent()) this.addProvenance(relationMention.get()); return this; }