def skosify_process(voc): logging.info("Performing inferences") skosify = Skosify() skosify.infer_classes(voc) skosify.infer_properties(voc) # logging.info("Setting up namespaces") # skosify.setup_namespaces(voc, namespaces) # logging.info("Phase 4: Transforming concepts, literals and relations") # special transforms for labels: whitespace, prefLabel vs altLabel # skosify.transform_labels(voc, options.default_language) # special transforms for collections + aggregate and deprecated concepts # skosify.transform_collections(voc) # find concept schema and update date modified cs = skosify.get_concept_scheme(voc) skosify.initialize_concept_scheme(voc, cs, label=False, language='nb', set_modified=True) # skosify.transform_aggregate_concepts(voc, cs, relationmap, options.aggregates) # skosify.transform_deprecated_concepts(voc, cs) # logging.info("Phase 5: Performing SKOS enrichments") # Enrichments: broader <-> narrower, related <-> related # skosify.enrich_relations(voc, options.enrich_mappings, # options.narrower, options.transitive) # logging.info("Phase 6: Cleaning up") # Clean up unused/unnecessary class/property definitions and unreachable # triples # if options.cleanup_properties: # skosify.cleanup_properties(voc) # if options.cleanup_classes: # skosify.cleanup_classes(voc) # if options.cleanup_unreachable: # skosify.cleanup_unreachable(voc) # logging.info("Phase 7: Setting up concept schemes and top concepts") # setup inScheme and hasTopConcept # skosify.setup_concept_scheme(voc, cs) # skosify.setup_top_concepts(voc, options.mark_top_concepts) logging.info("Phase 8: Checking concept hierarchy") # check hierarchy for cycles skosify.check_hierarchy(voc, break_cycles=True, keep_related=False, mark_top_concepts=False, eliminate_redundancy=True)
def enrich_and_concat(files, out_file): graph = Graph() for sourcefile in files: graph.load(sourcefile, format="turtle") skosify = Skosify() # Enrichments: broader <-> narrower, related <-> related logger.debug("Skosify: Enriching relations") skosify.enrich_relations(graph, False, True, True) with open(out_file + ".tmp", "w") as handle: graph.serialize(handle, format="turtle") os.rename(out_file + ".tmp", out_file) return len(graph)
def skosify_process(voc): # logging.info("Performing inferences") skosify = Skosify() # Perform RDFS subclass inference. # Mark all resources with a subclass type with the upper class. # skosify.infer_classes(voc) # skosify.infer_properties(voc) # logging.info("Setting up namespaces") # skosify.setup_namespaces(voc, namespaces) # logging.info("Phase 4: Transforming concepts, literals and relations") # special transforms for labels: whitespace, prefLabel vs altLabel # skosify.transform_labels(voc, options.default_language) # special transforms for collections + aggregate and deprecated concepts # skosify.transform_collections(voc) # find concept schema and update date modified cs = skosify.get_concept_scheme(voc) skosify.initialize_concept_scheme(voc, cs, label=False, language='nb', set_modified=True) # skosify.transform_aggregate_concepts(voc, cs, relationmap, options.aggregates) # skosify.transform_deprecated_concepts(voc, cs) # logging.info("Phase 5: Performing SKOS enrichments") # Enrichments: broader <-> narrower, related <-> related # skosify.enrich_relations(voc, options.enrich_mappings, # options.narrower, options.transitive) # logging.info("Phase 6: Cleaning up") # Clean up unused/unnecessary class/property definitions and unreachable # triples # if options.cleanup_properties: # skosify.cleanup_properties(voc) # if options.cleanup_classes: # skosify.cleanup_classes(voc) # if options.cleanup_unreachable: # skosify.cleanup_unreachable(voc) # logging.info("Phase 7: Setting up concept schemes and top concepts") # setup inScheme and hasTopConcept # skosify.setup_concept_scheme(voc, cs) # skosify.setup_top_concepts(voc, options.mark_top_concepts) # logging.info("Phase 8: Checking concept hierarchy") # check hierarchy for cycles skosify.check_hierarchy(voc, break_cycles=True, keep_related=False, mark_top_concepts=False, eliminate_redundancy=True)