def rdfs_properties(rdf):
    """Perform RDFS subproperty inference.

    Add superproperties where subproperties have been used."""

    # find out the subproperty mappings
    superprops = {}  # key: property val: set([superprop1, superprop2..])
    for s, o in rdf.subject_objects(RDFS.subPropertyOf):
        superprops.setdefault(s, set())
        for sp in rdf.transitive_objects(s, RDFS.subPropertyOf):
            if sp != s:
                superprops[s].add(sp)

    # add the superproperty relationships
    for p, sps in superprops.items():
        logging.debug("setting superproperties: %s -> %s", p, str(sps))
        for s, o in rdf.subject_objects(p):
            for sp in sps:
                rdf.add((s, sp, o))
def rdfs_properties ( rdf ) : superprops = { } for s , o in rdf . subject_objects ( RDFS . subPropertyOf ) : superprops . setdefault ( s , set ( ) ) for sp in rdf . transitive_objects ( s , RDFS . subPropertyOf ) : if sp != s : superprops [ s ] . add ( sp ) for p , sps in superprops . items ( ) : logging . debug ( "setting superproperties: %s -> %s" , p , str ( sps ) ) for s , o in rdf . subject_objects ( p ) : for sp in sps : rdf . add ( ( s , sp , o ) )
Perform RDFS subproperty inference.

    Add superproperties where subproperties have been used.