owlapy.agen_kg.helper

Attributes

RDFS_COMMENT_IRI

RDFS_LABEL_IRI

american_to_british

task_example_mapping

T

Functions

configure_dspy(signature)

run_query(query)

Runs a SPARQL query against the DBpedia SPARQL endpoint.

extract_hierarchy_from_dbpedia(cls)

Extracts the hierarchy of an entity from DBpedia using the SPARQL endpoint.

chunked_iterator(→ Iterator[list[T]])

Splits an iterable into fixed-size chunks and yields them sequentially.

Module Contents

owlapy.agen_kg.helper.RDFS_COMMENT_IRI = 'http://www.w3.org/2000/01/rdf-schema#comment'
owlapy.agen_kg.helper.RDFS_LABEL_IRI = 'http://www.w3.org/2000/01/rdf-schema#label'
owlapy.agen_kg.helper.american_to_british
owlapy.agen_kg.helper.task_example_mapping
owlapy.agen_kg.helper.configure_dspy(signature)[source]
owlapy.agen_kg.helper.run_query(query)[source]

Runs a SPARQL query against the DBpedia SPARQL endpoint.

owlapy.agen_kg.helper.extract_hierarchy_from_dbpedia(cls)[source]

Extracts the hierarchy of an entity from DBpedia using the SPARQL endpoint.

Parameters:

cls (str) – The DBpedia class remainder.

Returns:

A tuple containing two lists:
  • superclasses: List of superclasses of the entity.

  • subclasses: List of subclasses of the entity.

Return type:

tuple

owlapy.agen_kg.helper.T
owlapy.agen_kg.helper.chunked_iterator(seq: Iterable[T], size: int = 20) → Iterator[list[T]][source]

Splits an iterable into fixed-size chunks and yields them sequentially.

This function consumes the input iterable lazily and groups its elements into lists of a maximum given size. It is useful for batching data for processing, such as API calls or LLM requests.

Parameters:
  • seq (Iterable[T]) – The input iterable to be chunked.

  • size (int) – The maximum number of elements per chunk. Defaults to 50.

Returns:

An iterator over lists, where each list contains up to size elements from the input iterable.

Return type:

Iterator[list[T]]