owlapy.agen_kg.signatures

Classes

Entity

Triple

TypeAssertion

TypeGeneration

Literal

SPLTriples

Domain

DomainSpecificFewShotGenerator

EntityDeduplication

CoherenceChecker

TypeClustering

RelationClustering

TextSummarizer

ChunkSummarizer

EntityDeduplicationWithSummary

TypeClusteringWithSummary

RelationClusteringWithSummary

IncrementalEntityMerger

IncrementalTripleMerger

IncrementalTypeMerger

PlanDecomposer

BatchRdfsCommentGenerator

Module Contents

class owlapy.agen_kg.signatures.Entity(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""Given a piece of text as input identify key entities extracted form the text. The result
    should be a list of capitalized entities. E.g., ["ENTITY1", "ENTITY2", ...]"""
text: str = None
few_shot_examples: str = None
task_instructions: str = None
entities: list[str] = None
class owlapy.agen_kg.signatures.Triple(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""Given a piece of text and entities, identify triples of type source_entity-relation-target_entity
    where source_entity and target_entity are strictly part of the given entities."""
text: str = None
entities: list[str] = None
task_instructions: str = None
few_shot_examples: str = None
triples: list[tuple[str, str, str]] = None
class owlapy.agen_kg.signatures.TypeAssertion(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = 'Given a list of entities, a list of types and textual contex, assign types to the entities.'
text: str = None
entities: list[str] = None
entity_types: list[str] = None
few_shot_examples: str = None
task_instructions: str = None
pairs: list[tuple[str, str]] = None
class owlapy.agen_kg.signatures.TypeGeneration(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = 'Given a list of entities and textual contex, assign meaningful general types to the entities.'
text: str = None
entities: list[str] = None
few_shot_examples: str = None
task_instructions: str = None
pairs: list[tuple[str, str]] = None
class owlapy.agen_kg.signatures.Literal(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""Given a piece of text as input identify key numerical values extracted form the text. The result
    should be a list of numerical literals. E.g., ["123", "45.67", "50%", ...]"""
text: str = None
task_instructions: str = None
few_shot_examples: str = None
l_values: list[str] = None
class owlapy.agen_kg.signatures.SPLTriples(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""Given a piece of text, entities and numeric literals, identify triples of type
    source_entity-relation-target_value where source_entity is strictly part of the given entities and the target_value
    is strictly part of the given numeric literals."""
text: str = None
entities: list[str] = None
numeric_literals: list[str] = None
task_instructions: str = None
few_shot_examples: str = None
triples: list[tuple[str, str, str]] = None
class owlapy.agen_kg.signatures.Domain(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""Given a piece of text, identify the primary domain or topic of the text.
    Example domains: 'biology', 'chemistry', 'finance', 'sports', 'politics', 'medicine', 'computer science'.
    """
text: str = None
domain: str = None
class owlapy.agen_kg.signatures.DomainSpecificFewShotGenerator(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""Given a domain (e.g., 'biology', 'finance', 'sports'), generate few-shot examples tailored to that domain
    for a specific task (entity extraction, triple extraction, type assertion, etc.). The examples should follow the same
    format as the general few-shot examples but with domain-specific content."""
domain: str = None
task_type: str = None
num_examples: int = None
examples_example_structure: str = None
few_shot_examples: str = None
class owlapy.agen_kg.signatures.EntityDeduplication(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""Given a list of entities, identify and remove redundant near-duplicates that refer to the same real-world entity.
    Consider variations in spelling, abbreviations, and naming conventions. For example, given ['Ben Smith', 'B. Smith'],
    remove 'B. Smith' and keep 'Ben Smith'. Preserve most entities - only filter out those that are very closely resembled or
    abbreviated versions of more complete entities. Return a filtered list with redundant entities removed."""
entities: list[str] = None
text: str = None
filtered_entities: list[str] = None
class owlapy.agen_kg.signatures.CoherenceChecker(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""Given a batch of triples, textual context and optional instructions, evaluate the logical coherence and factual consistency
    of the triples. Rate each triple's coherence on a scale of 1-5, where 1 means incoherent, contradictory or trivial and 5 means highly
    coherent and consistent. Identify any contradictions or logical inconsistencies between triples."""
triples: list[tuple[str, str, str]] = None
text: str = None
task_instructions: str = None
coherence_scores: list[tuple[tuple[str, str, str], int, str]] = None
class owlapy.agen_kg.signatures.TypeClustering(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""Given a list of entity types, identify duplicates and near-duplicates that refer to the same conceptual type.
    Consider variations in spelling, singular/plural forms, synonyms, and different naming conventions. Return clusters of types
    that should be merged together, along with the canonical type name to use for each cluster."""
types: list[str] = None
text: str = None
clusters: list[tuple[list[str], str]] = None
class owlapy.agen_kg.signatures.RelationClustering(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""Given a list of relations, identify duplicates and near-duplicates that refer to the same relationship.
    Consider variations in spelling, synonyms, different phrasings, and naming conventions. Return clusters of relations
    that should be merged together, along with the canonical relation name to use for each cluster."""
relations: list[str] = None
text: str = None
clusters: list[tuple[list[str], str]] = None
class owlapy.agen_kg.signatures.TextSummarizer(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""Given a piece of text, generate a concise summary that preserves all key entities, relationships,
    types, and factual information mentioned. The summary should capture the essential semantic content without
    losing important details needed for knowledge graph extraction."""
text: str = None
summary: str = None
class owlapy.agen_kg.signatures.ChunkSummarizer(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""Given multiple text chunk summaries, combine them into a unified comprehensive summary.
    The combined summary should deduplicate information, preserve all unique entities and relationships,
    and maintain coherence across the merged content."""
chunk_summaries: list[str] = None
combined_summary: str = None
class owlapy.agen_kg.signatures.EntityDeduplicationWithSummary(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""Given a list of entities and a summary of the source text, identify and remove redundant near-duplicates
    that refer to the same real-world entity. Consider variations in spelling, abbreviations, and naming conventions.
    For example, given ['Ben Smith', 'B. Smith'], remove 'B. Smith' and keep 'Ben Smith'. Preserve most entities - only
    filter out those that are very closely resembled or abbreviated versions of more complete entities.
    Return a filtered list with redundant entities removed."""
entities: list[str] = None
summary: str = None
filtered_entities: list[str] = None
class owlapy.agen_kg.signatures.TypeClusteringWithSummary(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""Given a list of entity types and a summary of the source text, identify duplicates and near-duplicates
    that refer to the same conceptual type. Consider variations in spelling, singular/plural forms, synonyms,
    and different naming conventions. Return clusters of types that should be merged together,
    along with the canonical type name to use for each cluster."""
types: list[str] = None
summary: str = None
clusters: list[tuple[list[str], str]] = None
class owlapy.agen_kg.signatures.RelationClusteringWithSummary(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""Given a list of relations and a summary of the source text, identify duplicates and near-duplicates
    that refer to the same relationship. Consider variations in spelling, synonyms, different phrasings,
    and naming conventions. Return clusters of relations that should be merged together,
    along with the canonical relation name to use for each cluster."""
relations: list[str] = None
summary: str = None
clusters: list[tuple[list[str], str]] = None
class owlapy.agen_kg.signatures.IncrementalEntityMerger(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""Given two sets of entities from different text chunks along with context, merge them into a unified
    list. Identify entities that refer to the same real-world entity across chunks and produce a canonical list.
    Consider different mentions, abbreviations, and naming conventions that may appear across chunks."""
entities_a: list[str] = None
entities_b: list[str] = None
context_a: str = None
context_b: str = None
merged_entities: list[str] = None
entity_mapping: list[tuple[str, str]] = None
class owlapy.agen_kg.signatures.IncrementalTripleMerger(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""Given two sets of triples from different text chunks along with context, merge them into a unified
    list. Identify triples that represent the same relationship (possibly with different wording) and produce
    a canonical list. Handle variations in entity names and relation phrasings across chunks."""
triples_a: list[tuple[str, str, str]] = None
triples_b: list[tuple[str, str, str]] = None
context_a: str = None
context_b: str = None
merged_triples: list[tuple[str, str, str]] = None
class owlapy.agen_kg.signatures.IncrementalTypeMerger(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""Given two sets of entity-type pairs from different text chunks, merge them into a unified list.
    Resolve any conflicting type assignments for the same entity, preferring more specific types.
    Handle variations in type naming across chunks."""
types_a: list[tuple[str, str]] = None
types_b: list[tuple[str, str]] = None
context_a: str = None
context_b: str = None
merged_types: list[tuple[str, str]] = None
class owlapy.agen_kg.signatures.PlanDecomposer(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""We want to extract knowledge from text in triples format. The pipeline follows these steps:
    entity extraction, triple extraction, type assertion, literal extraction, triple extraction with numeric literals.
    Given the user's query about the knowledge graph to be extracted, decompose it into sub-tasks that can be used
    as instructions for each step of the pipeline."""
user_request: str = None
entity_extraction_task: str = None
triple_extraction_task: str = None
type_generation_task: str = None
type_assertion_task: str = None
literal_extraction_task: str = None
triple_with_literal_extraction_task: str = None
fact_checking_task: str = None
class owlapy.agen_kg.signatures.BatchRdfsCommentGenerator(/, **data: Any)[source]

Bases: dspy.Signature

__doc__ = Multiline-String
Show Value
"""We want to generate rdfs:comment annotations for OWL ontology entities.

    ENTITY SEMANTICS:
    - class: TBox concept (universal category).
    - property: TBox relation (no concrete values allowed).
    - individual: ABox instance (named individual in the ontology).

    CRITICAL RULES:
    - NEVER invent facts not present in the context or IRI.
    - For classes and properties: describe ONLY general meaning (TBox level).
    - For individuals: describe their role according to the context's content.
    - If no grounded description exists, return null.
    - For each comment, internally identify which phrases from the context support it; do not include unsupported concepts.
    - Keep comments concise and ontology-style, not narrative."""
context: str = None
iri_type_pairs: list[tuple[str, str]] = None
entity_comment_pairs: list[tuple[str, str | None]] = None