Skip to content

Commit

Permalink
feat(table): experimental conversion to table
Browse files Browse the repository at this point in the history
  • Loading branch information
bindeali committed Jan 5, 2025
1 parent 174786f commit c2eb8b3
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/OFNToTable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import csv
from ofnClasses import *


def OFNToTable(vocabulary: Vocabulary):
with open("output.csv", "w", newline="", encoding="utf-8") as csvfile:
csvwriter = csv.writer(csvfile)
for term in [x for x in vocabulary.terms if isinstance(x, TermClass)]:
name = term.name["cs"]
type = ""
if (term.type == ClassType.SUBJECT):
type = "Subjekt práva"
elif (term.type == ClassType.OBJECT):
type = "Objekt práva"
desc = term.description["cs"] if "cs" in term.description else ""
defi = term.definition["cs"] if "cs" in term.definition else ""
src = term.source
sco = ";".join(term.subClassOf)
csvwriter.writerow([name, type, desc, defi, src, sco])
for term in [x for x in vocabulary.terms if isinstance(x, Trope)]:
name = term.name["cs"]
dom = term.target if term.target is not None else ""
desc = term.description["cs"] if "cs" in term.description else ""
defi = term.definition["cs"] if "cs" in term.definition else ""
src = term.source
sco = ";".join(term.subClassOf)
csvwriter.writerow([name, dom, desc, defi, src, sco])
for term in [x for x in vocabulary.terms if isinstance(x, Relationship)]:
name = term.name["cs"]
dom = term.domain
ran = term.range
desc = term.description["cs"] if "cs" in term.description else ""
defi = term.definition["cs"] if "cs" in term.definition else ""
src = term.source
sco = ";".join(term.subClassOf)
csvwriter.writerow([dom, name, ran, desc, defi, src, sco])

0 comments on commit c2eb8b3

Please sign in to comment.