def cleanup_classes(rdf):
for t in (OWL.Class, RDFS.Class):<EOL><INDENT>for cl in rdf.subjects(RDF.type, t):<EOL><INDENT>if cl.startswith(SKOS):<EOL><INDENT>logging.debug("<STR_LIT>", cl)<EOL>replace_subject(rdf, cl, None)<EOL>continue<EOL><DEDENT>if rdf.value(None, RDF.type, cl, any=True) is not None:<EOL><INDENT>continue<EOL><DEDENT>if rdf.value(None, RDFS.domain, cl, any=True) is not None:<EOL><INDENT>continue<EOL><DEDENT>if rdf.value(None, RDFS.range, cl, any=True) is not None:<EOL><INDENT>continue<EOL><DEDENT>if rdf.value(None, OWL.equivalentClass, cl, any=True) is not None:<EOL><INDENT>continue<EOL><DEDENT>if (cl, RDF.type, SKOS.Concept) in rdfor (cl, RDF.type, SKOS.Collection) in rdf:<EOL><INDENT>logging.debug("<STR_LIT>", cl)<EOL>rdf.remove((cl, RDF.type, t))<EOL><DEDENT>else:  <EOL><INDENT>logging.debug("<STR_LIT>", cl)<EOL>replace_subject(rdf, cl, None)<EOL><DEDENT><DEDENT><DEDENT>
Remove unnecessary class definitions: definitions of SKOS classes or
       unused classes. If a class is also a skos:Concept or skos:Collection,
       remove the 'classness' of it but leave the Concept/Collection.