Skip to content

Are there a better way to do this? #2381

@miguelsmuller

Description

@miguelsmuller

I have the following code snippet...
With it I separate and later put together a ttl again.

graph = Graph()

for file in os.listdir(PATH):
    if file.endswith(".ttl"):
        graph.parse(os.path.join(PATH, file))

graph_class = Graph()
graph_properties = Graph()

graph_class += graph.triples((None, RDF.type, OWL.Class))
graph_properties += graph.triples((None, RDF.type, OWL.ObjectProperty))

graph_full = graph_class + graph_properties

I keep looking at the code and I don't like the aesthetics very much.
Is there any other way to do this, that is, build a graph with only the existing classes and properties in the original?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions