fastrdf.describe¶
Model.describe: a summary of what is in each graph of a model.
A prototype in Python on top of Model.analyze and SPARQL, to settle the shape of the summary before the counts move into the engine.
The tables of a ModelDescription hold everything that was computed. Their size is bounded by the schema (graphs, predicates and classes), never by the number of triples. The text and dict forms are bounded further: see ModelDescription.to_text.
Attributes¶
Classes¶
What changed between two descriptions, from ModelDescription.diff: the predicates and classes |
|
The result of Model.describe. Printing it gives a report of bounded length as aligned |
Functions¶
|
See Model.describe. |
|
The namespace of an IRI: up to and including the last '#', else the last '/', else the |
Module Contents¶
- class fastrdf.describe.DescriptionDiff(predicates: polars.DataFrame, classes: polars.DataFrame, short=None)¶
What changed between two descriptions, from ModelDescription.diff: the predicates and classes whose number of triples or instances differ, as DataFrames with before, after and change. Printing it gives tables; to_text(format=”markdown”) gives them as Markdown.
- classes¶
- predicates¶
- class fastrdf.describe.ModelDescription(tables: Dict[str, polars.DataFrame], sections: Sequence[str], prefixes: Dict[str, str])¶
The result of Model.describe. Printing it gives a report of bounded length as aligned tables (see to_text); to_markdown gives the same report as Markdown, which notebooks show. The tables are polars DataFrames with everything that was computed. The table of a section that was not asked for is empty.
sections: the sections that were computed.
graphs: one row per graph: graph, triples, predicates, classes, namespaces, and with the subjects section subjects, untyped_subjects and blank_subjects.
predicates: one row per graph and predicate: graph, predicate, triples, distinct_subjects, distinct_objects, exact (whether the distinct counts are exact), subject_kinds (IRI, Blank), object_types (IRI, Blank or the datatype IRI), object_type_triples, max_triples_per_subject, max_triples_per_object, functional (at most one object per subject) and inverse_functional (at most one subject per object), both None when the statistics cannot tell, common_objects and common_object_counts (the most common objects, as N-Triples terms), example (examples section), declared and label (vocabulary section).
classes: graph, class, instances, and with the vocabulary section declared and label.
namespaces: graph, namespace, prefix (the prefix the report uses: a well-known prefix, or one made from the namespace for the namespaces of predicates and classes), role (predicate, class, and with the iri_namespaces section subject and object) and terms (the distinct IRIs of that role in the namespace).
class_predicates: for each class, the predicates its instances have: graph, class, predicate, instances, subjects (instances with the predicate), coverage (subjects / instances), triples, min_per_subject and max_per_subject (among the instances that have it).
links: which classes are linked: graph, subject_class, predicate, object_class, triples.
literals: graph, predicate, datatype, min and max (as strings, not for strings), min_length and max_length (strings only).
languages: graph, predicate, language, triples.
dangling: IRI objects that are not a subject in their graph: graph, predicate, objects, triples, in_other_graphs (how many of the objects are a subject in another graph).
overlap: for pairs of the largest graphs: graph_a, graph_b, shared_predicates, shared_classes, shared_subjects, a_refers_to_b (IRI objects of a that are subjects in b), b_refers_to_a.
- diff(other: ModelDescription) DescriptionDiff¶
What changed from other (before) to this description (after), e.g. around a mapping or an inference run: the predicates and classes whose triples or instances differ.
- show_class(cls: str, graph: str | None | List[str | None] = '*', format: str = 'text') str¶
The whole profile of one class: its instances, its predicates with the share of instances that have them and the objects per instance, and its links to and from other classes. Needs the class_predicates section for the predicates and the links section for the links.
- Parameters:
cls – The class as an IRI, <IRI> or prefix:local with a prefix of the report.
graph – A graph (None for the default graph); every graph with the class by default.
format – “text” or “markdown”.
- show_predicate(predicate: str, format: str = 'text') str¶
Everything about one predicate in every graph that has it: counts, object types, the most common objects, literal ranges and languages, and the classes that use it.
- Parameters:
predicate – The predicate as an IRI, <IRI> or prefix:local with a prefix of the report.
format – “text” or “markdown”.
- to_dict(max_rows: int | None = None, max_graphs: int | None = None) dict¶
The summary as plain dicts and lists, e.g. for JSON or as context for a language model.
- Parameters:
max_rows – Keep at most this many rows per table and graph (the largest first).
max_graphs – Keep only the this many largest graphs.
- to_markdown(**kwargs) str¶
The report as Markdown, with a table per section: to_text(format=”markdown”, …).
- to_text(graphs: List[str | None] | None = None, sections: List[str] | None = None, max_graphs: int | None = 5, max_rows: int | None = 15, max_chars: int | None = None, format: str = 'text', width: int | None = 100) str¶
The report: a table of the graphs, then for each of the largest graphs a table per section. Its length does not grow with the model: the overview has the largest max_rows graphs, max_graphs graphs are detailed, and each table has at most max_rows rows, the largest first. Graphs with the same predicates as a graph already detailed are only named. What is left out is counted in “… n more” lines. Printing the description is to_text(max_chars=20_000).
To see more, raise the limits (None for no limit), ask for one graph or section, read the DataFrames, or use show_class and show_predicate.
- Parameters:
graphs – Detail these graphs (None in the list is the default graph) instead of the largest.
sections – Only these sections of the details.
max_graphs – The number of graphs to detail.
max_rows – The number of rows per table.
max_chars – Halve max_rows, then max_graphs, until the report is at most this long.
format – “text” for aligned columns, “markdown” for Markdown headings and tables.
width – The longest line of the text format: the widest columns of a table that is wider are cut with an ellipsis (the DataFrames and Markdown have the cells in full). Headers are not cut, so a table with many columns can stay wider than a small width. None for no limit.
- class_predicates¶
- classes¶
- dangling¶
- graphs¶
- languages¶
- links¶
- literals¶
- namespaces¶
- overlap¶
- predicates¶
- sections¶
- fastrdf.describe.describe(m, graphs: List[str | None] | None = None, sections: None | str | Sequence[str] = None, exact: bool = False, max_overlap_graphs: int = 6) ModelDescription¶
See Model.describe.
- fastrdf.describe.namespace_of(iri: str) str¶
The namespace of an IRI: up to and including the last ‘#’, else the last ‘/’, else the last ‘:’.
- fastrdf.describe.DEFAULT_SECTIONS = ('predicates', 'classes', 'namespaces')¶
- fastrdf.describe.EXTRA_SECTIONS = ('subjects', 'class_predicates', 'links', 'literals', 'examples', 'dangling', 'overlap',...¶
- fastrdf.describe.OWL = 'http://www.w3.org/2002/07/owl#'¶
- fastrdf.describe.RDF = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'¶
- fastrdf.describe.RDFS = 'http://www.w3.org/2000/01/rdf-schema#'¶
- fastrdf.describe.RDF_TYPE = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'¶
- fastrdf.describe.SECTIONS = ('predicates', 'classes', 'namespaces', 'subjects', 'class_predicates', 'links', 'literals',...¶
- fastrdf.describe.XSD = 'http://www.w3.org/2001/XMLSchema#'¶