Skip to content

Commit

Permalink
Add datastrukturterm to concept #4
Browse files Browse the repository at this point in the history
  • Loading branch information
stigbd committed Mar 13, 2020
1 parent 8a14851 commit 6484614
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
26 changes: 21 additions & 5 deletions concepttordf/concept.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ def alternativeterm(self, alternativeterm: dict):
self._alternativeterm = alternativeterm

@property
def hiddenterm(self) -> dict:
return self._hiddenterm
def datastrukturterm(self) -> dict:
return self._datastrukturterm

@hiddenterm.setter
def hiddenterm(self, hiddenterm: dict):
self._hiddenterm = hiddenterm
@datastrukturterm.setter
def datastrukturterm(self, datastrukturterm: dict):
self._datastrukturterm = datastrukturterm

@property
def subject(self) -> dict:
Expand Down Expand Up @@ -253,6 +253,22 @@ def _add_concept_to_graph(self):
self._g.add((URIRef(self.identifier),
SKOSXL.hiddenLabel, hiddenLabel))

# datastrukturterm
if hasattr(self, 'datastrukturterm'):
datastrukturterm = BNode()
self._g.add((datastrukturterm, RDF.type, SKOSXL.Label))
if 'name' in self.datastrukturterm:
_name = self.datastrukturterm['name']
for key in _name:
for l in _name[key]:
self._g.add((datastrukturterm, SKOSXL.literalForm,
Literal(l, lang=key)))
if 'modified' in self.datastrukturterm:
self._g.add((datastrukturterm, DCT.modified,
Literal(self.datastrukturterm['modified'],
datatype=XSD.date)))
self._g.add((URIRef(self.identifier),
SKOSNO.datastrukturterm, datastrukturterm))
# definition
if hasattr(self, 'definition'):
self._add_betydningsbeskrivelse_to_concept(self.definition)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="concepttordf",
version="1.0.0.rc3",
version="1.0.0.rc4",
author="Stig B. Dørmænen",
author_email="[email protected]",
description=(
Expand Down
6 changes: 6 additions & 0 deletions tests/completeconcept.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
},
"modified": "2020-03-03"
},
"datastrukturterm": {
"name": {
"en": ["completeConcept"]
},
"modified": "2020-03-13"
},
"subject": {
"en": "terminology",
"nb": "termonologi",
Expand Down
4 changes: 4 additions & 0 deletions tests/completeconcept.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
skosxl:literalForm "completeconcept"@en , "kompletomgrep"@nn , "kompletbegrep"@nb ;
dct:modified "2020-03-03"^^xsd:date ;
] ;
skosno:datastrukturterm [ a skosxl:Label ;
skosxl:literalForm "completeConcept"@en ;
dct:modified "2020-03-13"^^xsd:date ;
] ;
dcat:contactPoint [ a vcard:Organization ;
vcard:hasEmail <mailto:[email protected]> ;
vcard:hasOrganizationName "Norwegian Digitalisation Agency"@en,
Expand Down
1 change: 1 addition & 0 deletions tests/test_concept.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def test_concept_to_rdf_should_return_skos_concept():
concept.term = _concept['term']
concept.alternativeterm = _concept['alternativeterm']
concept.hiddenterm = _concept['hiddenterm']
concept.datastrukturterm = _concept['datastrukturterm']
# Definisjon
definition = Definition()
definition.text = _concept['definition']['text']
Expand Down

0 comments on commit 6484614

Please sign in to comment.