Hyperedge Nodes & Event Projection
Hyperedge Nodes & Event Projection
Section titled “Hyperedge Nodes & Event Projection”Problem Statement
Section titled “Problem Statement”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 `uvachaTarget (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.
Proposed Solution: EventHeader
Section titled “Proposed Solution: EventHeader”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.
Semantic Meaning
Section titled “Semantic Meaning”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.
Projection Strategy
Section titled “Projection Strategy”To support multi-lingual output, the Projector can be updated to handle EventHeader nodes by matching them against a template, similar to standard commands.
1. Template Definition
Section titled “1. Template Definition”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 ] ]]2. Compiler Logic
Section titled “2. Compiler Logic”When the compiler encounters ( sanjaya uvacha ):
- Resolve Entities: It resolves
sanjayato the entity defined in the registry. - Resolve Action: It identifies
uvachaas the action. - Apply Template: It looks for a template matching the action (
uvacha). - 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.