Skip to content

Hyperedge Nodes & Event Projection

In narrative texts like the Mahabharata, speaker attribution is often repetitive and needs to be rendered differently based on the target audience or language.

Source:

`sanjaya `uvacha

Target (English):

Sanjaya said:

Target (Sanskrit):

सञ्जय उवाच

Currently, we model this as two separate commands: a speaker entity (sanjaya) and an action (uvacha). However, this relies on linear processing and doesn’t capture the event effectively.

The Vyasa syntax supports Event Headers, which act as hyperedge nodes connecting multiple entities in an event tuple.

Syntax:

( sanjaya uvacha )

This parses into a Node::EventHeader containing a tuple of commands.

This node represents a Hyperedge connecting:

  • Subject: sanjaya (Entity)
  • Verb/Action: uvacha (Action)
  • Context: The simpler linear stream implies this event applies to the following block.

To support multi-lingual output, the Projector can be updated to handle EventHeader nodes by matching them against a template, similar to standard commands.

We can define a template for the event concept, or speculatively, for the specific tuple signature.

A more flexible approach is to map the Action to a template that accepts the Subject.

Template (uvacha):

`template { target="html" name="uvacha" } [
`div { class="speaker-attribution" } [
`span { class="en" } [ $.subject.label_en said: ]
`span { class="sa" } [ $.subject.label_dev ]
]
]

When the compiler encounters ( sanjaya uvacha ):

  1. Resolve Entities: It resolves sanjaya to the entity defined in the registry.
  2. Resolve Action: It identifies uvacha as the action.
  3. Apply Template: It looks for a template matching the action (uvacha).
  4. Inject Context: It injects the subject’s properties ($.subject.*) into the template.

This allows the source text to remain minimal and semantic (( sanjaya uvacha ) or just sanjaya uvacha if we infer the tuple), while the output can be rich and localized.