This is a set of functions that I have been using to process an owl graph. Given base name and folder path, it loads and parse a local rdf/xml file and prints some of its content (object properties, individuals, etc).
The code contains the following functions:
create_class_by_name
Create a class given a nameget_classes
Get all classeshas_object_properties
Check if instance has object propertiesis_domain_or_range
Returns true if item is domain or range individual.get_object_properties
Get all the object properties of the ontologyget_data_properties
Get all the data properties of the ontologycheck_instance
Find an instance by string nameget_instance_classes
Get classes of an instanceget_class_by_name
Get a class by its string nameattach_instance_to_class
Attach an instance to a classget_individuals
Get all the individuals in the ontologyadd_data_property
Add one or more values as data properties of a specific type to an instanceget_uri
Create a uri given the base name and class namecreate_instance_of_class
Create an instance of a classremove_superclasses
Remove the superclasses of a given class if they are superclasses of a given super class (if we'd want to attach the given class to the given superclass)attach_class_to_subclass
Given a class name and that class super class name, and a sub class, assign the super class of that subclass, creating it if necessary. There can be more than one super class to assign (csv string).attach_class_to_superclass
Same as ```attach_class_to_subclass`` but for subclass,get_class
Given a class name and its super class name, we create that new class if it does not exist or we return the existing oneadd_object_property
Given an instance (domain) and an object property, assign another instance by name as range of the domain instance object property. There can be more than one (comma separated).is_instance_of_class
Returns True if the instance is of the class name. If descendants input argument is set to True then it looks for the subclasses too.