data_extraction
Classes
Functions
|
|
|
|
|
|
|
|
|
|
|
|
|
Module Contents
- class data_extraction.Entity
Bases:
dspy.Signature
- __doc__ = 'Given a piece of text as input identify key entities extracted form the text.'
- text: str
- few_shot_examples: str
- entities: list[str]
- class data_extraction.Triple
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
- entities: list[str]
- few_shot_examples: str
- triples: list[tuple[str, str, str]]
- class data_extraction.TypeAssertion
Bases:
dspy.Signature
- __doc__ = 'Given a list of entities, a list of types and textual contex, assign types to the entities.'
- text: str
- entities: list[str]
- entity_types: list[str]
- few_shot_examples: str
- pairs: list[tuple[str, str]]
- class data_extraction.TypeGeneration
Bases:
dspy.Signature
- __doc__ = 'Given a list of entities and textual contex, assign meaningful general types to the entities.'
- text: str
- entities: list[str]
- few_shot_examples: str
- pairs: list[tuple[str, str]]
- class data_extraction.Literal
Bases:
dspy.Signature
- __doc__ = 'Given a piece of text as input identify key numerical values extracted form the text.'
- text: str
- few_shot_examples: str
- l_values: list[str]
- class data_extraction.SPLTriples
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
- entities: list[str]
- numeric_literals: list[str]
- few_shot_examples: str
- triples: list[tuple[str, str, str]]
- data_extraction.configure_dspy(signature)
- data_extraction.get_entities(text, few_shot_examples=EXAMPLES_FOR_ENTITY_EXTRACTION)
- data_extraction.get_triples(text, entities, few_shot_examples=EXAMPLES_FOR_TRIPLES_EXTRACTION)
- data_extraction.assign_types(text, entities, entity_types, few_shot_examples=EXAMPLES_FOR_TYPE_ASSERTION)
- data_extraction.generate_types(text, entities, few_shot_examples=EXAMPLES_FOR_TYPE_GENERATION)
- data_extraction.get_numeric_literals(text, few_shot_examples=EXAMPLES_FOR_LITERAL_EXTRACTION)
- data_extraction.get_spl_triples(text, entities, literals, few_shot_examples=EXAMPLES_FOR_SPL_TRIPLES_EXTRACTION)
- class data_extraction.GraphExtractor(model, api_key, api_base, temperature=0.1, seed=42, cache=False, cache_in_memory=False, enable_logging=False)
Bases:
dspy.Module
- logging = False
- entity_extractor
- triples_extractor
- type_asserter
- type_generator
- literal_extractor
- spl_triples_extractor
- static snake_case(text)
- forward(text: str, ontology_namespace='http://example.com/ontogen#', entity_types: List[str] = None, generate_types=False, extract_spl_triples=False, examples_for_entity_extraction=EXAMPLES_FOR_ENTITY_EXTRACTION, examples_for_triples_extraction=EXAMPLES_FOR_TRIPLES_EXTRACTION, examples_for_type_assertion=EXAMPLES_FOR_TYPE_ASSERTION, examples_for_type_generation=EXAMPLES_FOR_TYPE_GENERATION, examples_for_literal_extraction=EXAMPLES_FOR_LITERAL_EXTRACTION, examples_for_spl_triples_extraction=EXAMPLES_FOR_SPL_TRIPLES_EXTRACTION, save_path='generated_ontology.owl') owlapy.owl_ontology.Ontology
Extract an ontology from a given textual input.
- Parameters:
text (str) – Text input from which the ontology will be extracted.
ontology_namespace (str) – Namespace to use for the ontology.
entity_types (List[str]) – List of entity types to assign to extracted entities. Leave empty if generate_types is True.
generate_types (bool) – Whether to generate types for extracted entities.
extract_spl_triples (bool) – Whether to extract triples of type s-p-l where l is a numeric literal. This triples will be represented using data properties and a literal value of type string (although they are numeric values).
examples_for_entity_extraction (str) – Few-shot examples for entity extraction.
examples_for_triples_extraction (str) – Few-shot examples for triple extraction.
examples_for_type_assertion (str) – Few-shot examples for type assertion.
examples_for_type_generation (str) – Few-shot examples for type generation and assertion.
examples_for_literal_extraction (str) – Few-shot examples for literal extraction.
examples_for_spl_triples_extraction (str) – Few-shot examples for s-p-l triples extraction.
save_path (str) – Path to save the generated ontology.
Returns (Ontology): An ontology object.