Storage Operations
Turtle
Export your knowledge graph to a Turtle (TTL) file or string to interoperate with RDF-compatible tools.
The Perseus SDK allows you to export a KnowledgeGraph object to a Turtle (TTL) file. TTL is a standard serialization format for RDF graphs, making it easy to share and interoperate with other RDF-compatible tools.
Saving the Graph to a TTL File
You can use the save_ttl() method on a KnowledgeGraph object to save it to a local TTL file.
For more details on the save_ttl method, refer to the Python API.
import perseus_client
knowledge_graphs = perseus_client.build_graph(
file_paths=["assets/sample.txt"],
)
for i, kg in enumerate(knowledge_graphs):
file_path = f"./output/graph_{i}.ttl"
kg.save_ttl(file_path)Getting TTL as a String Variable
For more details on the to_ttl method, refer to the Python API.
import perseus_client
knowledge_graphs = perseus_client.build_graph(
file_paths=["assets/sample.txt"],
)
for kg in knowledge_graphs:
ttl_content = kg.to_ttl()