Skosify API Reference

skosify.skosify(*sources, **config)[source]

Convert, extend, and check SKOS vocabulary.

skosify.config(file=None)[source]

Get default configuration and optional settings from config file.

  • file: can be a filename or a file object

Checks/fixes are bundled in one namespace.

skosify.check.disjoint_relations(rdf, fix=False)[source]

Check if the graph contains concepts connected by both of the semantically disjoint semantic skos:related and skos:broaderTransitive (S27), and optionally remove the involved skos:related relations.

Parameters:
  • rdf (Graph) – An rdflib.graph.Graph object.
  • fix (bool) – Fix the problem by removing skos:related relations that overlap with skos:broaderTransitive.
skosify.check.hierarchical_redundancy(rdf, fix=False)[source]

Check for and optionally remove extraneous skos:broader relations.

Parameters:
  • rdf (Graph) – An rdflib.graph.Graph object.
  • fix (bool) – Fix the problem by removing skos:broader relations between concepts that are otherwise connected by skos:broaderTransitive.
skosify.check.hierarchy_cycles(rdf, fix=False)[source]

Check if the graph contains skos:broader cycles and optionally break these.

Parameters:
  • rdf (Graph) – An rdflib.graph.Graph object.
  • fix (bool) – Fix the problem by removing any skos:broader that overlaps with skos:broaderTransitive.

Inference rules are bundled in one namespace.

skosify.infer.rdfs_classes(rdf)[source]

Perform RDFS subclass inference.

Mark all resources with a subclass type with the upper class.

skosify.infer.rdfs_properties(rdf)[source]

Perform RDFS subproperty inference.

Add superproperties where subproperties have been used.

skosify.infer.skos_hierarchical(rdf, narrower=True)[source]

Infer skos:broader/skos:narrower (S25) but only keep skos:narrower on request.

Parameters:narrower (bool) – If set to False, skos:narrower will not be added, but rather removed.
skosify.infer.skos_hierarchical_mappings(rdf, narrower=True)[source]

Infer skos:broadMatch/skos:narrowMatch (S43) and add the super-properties skos:broader/skos:narrower (S41).

Parameters:narrower (bool) – If set to False, skos:narrowMatch will not be added, but rather removed.

Make sure that skos:related is stated in both directions (S23).

skosify.infer.skos_symmetric_mappings(rdf, related=True)[source]

Ensure that the symmetric mapping properties (skos:relatedMatch, skos:closeMatch and skos:exactMatch) are stated in both directions (S44).

Parameters:related (bool) – Add the skos:related super-property for all skos:relatedMatch relations (S41).
skosify.infer.skos_topConcept(rdf)[source]

Infer skos:topConceptOf/skos:hasTopConcept (S8) and skos:inScheme (S7).

skosify.infer.skos_transitive(rdf, narrower=True)[source]

Perform transitive closure inference (S22, S24).