Relations

data class Relations(val relations: List<Relation> = emptyList()) : Iterable<Relation>

A reusable, immutable collection of Relation types with a fluent builder API.

Build one up with withSemantic, withProcedural, etc., then pass it to a SourceAnalysisContext via withRelations. The same instance can be shared across multiple contexts.

val relations = Relations.empty()
.withSemantic("works at", "is employed by")
.withProcedural("prefers", "has preference for")
.withProceduralForSubject("Person", "likes", "dislikes", "prefers")

val context = SourceAnalysisContext.withContextId("ctx")
.withEntityResolver(resolver)
.withSchema(schema)
.withRelations(relations)

Constructors

Link copied to clipboard
constructor(relations: List<Relation> = emptyList())

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The relation types in this collection.

Functions

Link copied to clipboard
open fun forEach(p0: Consumer<in Relation>)
Link copied to clipboard

True if this collection has no relations.

Link copied to clipboard
open operator override fun iterator(): Iterator<Relation>
Link copied to clipboard
operator fun plus(relation: Relation): Relations

Returns a new collection with the given relation appended.

operator fun plus(other: Relations): Relations

Returns a new collection containing the relations from both.

Link copied to clipboard
fun size(): Int

Number of relations in this collection.

Link copied to clipboard
Link copied to clipboard

The relations as a plain list.

Link copied to clipboard
fun withEpisodic(predicate: String, meaning: String = predicate): Relations

Add an episodic (event-based) relation.

Link copied to clipboard
fun withPredicatesForSubject(subjectType: Class<*>, knowledgeType: KnowledgeType, vararg predicates: String): Relations

Same as withPredicatesForSubject but takes a class instead of a string — the subject type is recorded as the class simpleName. A mention's type must match it (case-insensitive) for an edge to project.

fun withPredicatesForSubject(subjectType: String, knowledgeType: KnowledgeType, vararg predicates: String): Relations

Add several relations at once, all sharing the same subject type and knowledge type. The predicate string is used as the meaning for each one.

Link copied to clipboard
fun withProcedural(predicate: String, meaning: String = predicate): Relations

Add a procedural (behavioral/preference) relation.

Link copied to clipboard
fun withProceduralForSubject(subjectType: String, predicate: String, meaning: String): Relations

Add a procedural relation that only applies when the subject is of the given type.

Link copied to clipboard
fun withProceduralPredicatesForSubject(subjectType: String, vararg predicates: String): Relations

Add several procedural relations at once for a subject type.

Link copied to clipboard
fun withSemantic(predicate: String, meaning: String = predicate): Relations

Add a semantic (factual) relation.

Link copied to clipboard
fun withSemanticBetween(subjectType: String, objectType: String, predicate: String, meaning: String): Relations

Add a semantic relation constrained to a specific subject and object type pair.

fun withSemanticBetween(subjectType: String, objectType: String, predicate: String, meaning: String, floor: EvidenceFloor?): Relations

Add a semantic relation constrained to a specific subject and object type pair, with an evidence floor declared inline. This lets you stay in the fluent builder chain rather than stepping outside it to call Relation.withEvidenceFloor separately.

Link copied to clipboard
fun withSemanticForSubject(subjectType: String, predicate: String, meaning: String): Relations

Add a semantic relation that only applies when the subject is of the given type.

Link copied to clipboard
fun withSemanticPredicatesForSubject(subjectType: String, vararg predicates: String): Relations

Add several semantic relations at once for a subject type.