-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(table): experimental conversion to table
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |