mirror of
https://github.com/OpenSPG/openspg.git
synced 2025-07-28 03:22:34 +00:00
34 lines
852 B
Python
34 lines
852 B
Python
import networkx as nx
|
|
import matplotlib.pyplot as plt
|
|
|
|
from knext.api.component import SPGTypeMapping
|
|
from knext.api.component import KGSinkWriter
|
|
from knext.api.component import CsvSourceReader
|
|
|
|
if __name__ == '__main__':
|
|
source = CsvSourceReader(
|
|
local_path="./builder/job/data/BodyPart.csv", columns=["id"], start_row=1
|
|
)
|
|
|
|
mapping1 = SPGTypeMapping(spg_type_name="Medical.BodyPart").add_field(
|
|
"id", "Medical.BodyPart.id"
|
|
)
|
|
|
|
mapping2 = SPGTypeMapping(spg_type_name="Medical.BodyPart").add_field(
|
|
"id", "Medical.BodyPart.id1"
|
|
)
|
|
|
|
sink = KGSinkWriter()
|
|
sink2 = KGSinkWriter()
|
|
|
|
builder_chain = source >> [mapping1, None] >> sink2
|
|
|
|
print(builder_chain.dag.edges)
|
|
|
|
G = builder_chain.dag
|
|
# 绘制图形
|
|
nx.draw(G, with_labels=True, arrows=True)
|
|
|
|
# 显示图形
|
|
plt.show()
|