Knowledge Domain

Domain schemas for knowledge management (Person, Work, Concept, Topic, Quote)

Person

Represents a human being, historical figure, or speaker referenced in content.


source

Person


def Person(
    data:Any
)->None:

A human being, historical figure, or speaker.

# Create a Person node
person = Person(name="Sun Tzu", role="Military Strategist", era="Ancient China")
print(f"Person: {person.name}")
print(f"Label: {person.get_label()}")
Person: Sun Tzu
Label: Person
# Convert to GraphNode
graph_node = person.to_graph_node()
print(f"GraphNode properties: {graph_node.properties}")
GraphNode properties: {'name': 'Sun Tzu', 'role': 'Military Strategist', 'era': 'Ancient China'}

Work

Represents a creative work such as a book, speech, article, or other authored content.


source

Work


def Work(
    data:Any
)->None:

A creative work (book, speech, article, etc.).

# Create a Work node
work = Work(title="The Art of War", author_name="Sun Tzu", year=-500)
print(f"Work: {work.title}")

# 'name' is auto-populated from 'title'
graph_node = work.to_graph_node()
print(f"GraphNode name: {graph_node.properties['name']}")
Work: The Art of War
GraphNode name: The Art of War

Concept

Represents an abstract idea, theory, or framework discussed in content.


source

Concept


def Concept(
    data:Any
)->None:

An abstract idea, theory, or framework.

# Create a Concept node
concept = Concept(
    name="Deception in Warfare",
    definition="The use of misdirection to gain strategic advantage",
    domain="Military Strategy"
)
print(f"Concept: {concept.name}")
print(f"Domain: {concept.domain}")
Concept: Deception in Warfare
Domain: Military Strategy

Topic

Represents a subject or theme discussed in content, typically extracted via topic modeling or NLP.


source

Topic


def Topic(
    data:Any
)->None:

A subject or theme discussed in content.

# Create a Topic node with confidence score
topic = Topic(name="Military Strategy", confidence=0.92)
print(f"Topic: {topic.name} (confidence: {topic.confidence})")
Topic: Military Strategy (confidence: 0.92)

Quote

Represents a specific verbatim segment of text that is noteworthy or frequently referenced.


source

Quote


def Quote(
    data:Any
)->None:

A verbatim segment of notable text.

# Create a Quote node
quote = Quote(
    text="All warfare is based on deception.",
    speaker="Sun Tzu"
)
print(f"Quote: '{quote.text}'")
print(f"Speaker: {quote.speaker}")
Quote: 'All warfare is based on deception.'
Speaker: Sun Tzu
# 'name' is auto-populated from 'text' (truncated)
graph_node = quote.to_graph_node()
print(f"GraphNode name: {graph_node.properties['name']}")
GraphNode name: All warfare is based on deception.

Example: Building a Knowledge Graph

from cjm_graph_plugin_system.core import SourceRef

# Source reference to a transcript
source = SourceRef(
    plugin_name="cjm-transcription-plugin-voxtral-hf",
    table_name="transcriptions",
    row_id="lecture-001"
)

# Create domain nodes
author = Person(name="Sun Tzu", role="Military Strategist")
book = Work(title="The Art of War", author_name="Sun Tzu")
concept = Concept(name="Deception", domain="Military Strategy")
quote = Quote(text="All warfare is based on deception.", speaker="Sun Tzu")

# Convert to GraphNodes with provenance
nodes = [
    author.to_graph_node(sources=[source]),
    book.to_graph_node(sources=[source]),
    concept.to_graph_node(sources=[source]),
    quote.to_graph_node(sources=[source])
]

print(f"Created {len(nodes)} graph nodes:")
for node in nodes:
    print(f"  - {node.label}: {node.properties.get('name', 'N/A')}")
Created 4 graph nodes:
  - Person: Sun Tzu
  - Work: The Art of War
  - Concept: Deception
  - Quote: All warfare is based on deception.