RelationBasedGraphProjector

class RelationBasedGraphProjector constructor(relations: Relations = Relations.empty(), policy: ProjectionPolicy = DefaultProjectionPolicy(), caseSensitive: Boolean = false, authorityResolver: AuthorityResolver = StructuralAuthorityResolver()) : GraphProjector

Graph projector that uses predicates from both the DataDictionary schema and Relations to determine relationship types.

Does not use LLM - matches proposition text directly against known predicates.

Matching priority:

  1. Schema relationships from DataDictionary.allowedRelationships with explicit predicates defined via @Semantics(With(key = Proposition.PREDICATE, value = "...")). Uses the property name as the relationship type.

  2. Schema relationships with derived predicates from the property name. For example, property employer derives predicate "has employer".

  3. Fallback to Relations predicates, deriving relationship type from predicate using UPPER_SNAKE_CASE convention.

Example with explicit @Semantics predicate:

// Given: Person.employer property annotated with @Semantics predicate="works at"
val schema = DataDictionary.fromClasses("myschema", Person::class.java, Company::class.java)
val projector = RelationBasedGraphProjector.from(Relations.empty())

// "Bob works at Acme" -> (bob)-[:employer]->(acme)
// Uses property name "employer" as relationship type

Example with derived predicate (no annotation needed):

// Given: Person.employer property with no @Semantics annotation
// Predicate "has employer" is derived automatically

// "Bob has employer Acme" -> (bob)-[:employer]->(acme)

Example with Relations fallback:

val relations = Relations.empty()
.withProcedural("likes", "expresses preference for")

val projector = RelationBasedGraphProjector.from(relations)

// "Alice likes jazz" -> (alice)-[:LIKES]->(jazz)
// Derives LIKES from predicate

Parameters

relations

The relation predicates to match against (fallback)

policy

Optional policy to filter propositions before projection

caseSensitive

Whether predicate matching is case-sensitive (default: false)

Constructors

Link copied to clipboard
constructor(relations: Relations = Relations.empty(), policy: ProjectionPolicy = DefaultProjectionPolicy(), caseSensitive: Boolean = false, authorityResolver: AuthorityResolver = StructuralAuthorityResolver())

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun project(proposition: Proposition, schema: <Error class: unknown class>): ProjectionResult<ProjectedRelationship>

Projects a single proposition to a graph relationship.

Link copied to clipboard
open override fun projectAll(propositions: List<Proposition>, schema: <Error class: unknown class>): ProjectionResults<ProjectedRelationship>

Projects a list of propositions, applying the configured policy to each.

Link copied to clipboard

Set the resolver that stamps each projected edge with its source authority.

Link copied to clipboard

Set case sensitivity for predicate matching.

Link copied to clipboard

Use a DefaultProjectionPolicy with default confidence threshold.

Use a DefaultProjectionPolicy with the given confidence threshold.

Link copied to clipboard

Use a LenientProjectionPolicy with default confidence threshold.

Use a LenientProjectionPolicy with the given confidence threshold.

Link copied to clipboard

Set the projection policy.

Link copied to clipboard

Add more relations to this projector.