Skip to content

Commit

Permalink
update of the templates for the vocabs so all terms are included
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricdcc committed Oct 23, 2024
1 parent d8477ce commit 26ba20e
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 42 deletions.
29 changes: 15 additions & 14 deletions templates/template_html.html
Original file line number Diff line number Diff line change
Expand Up @@ -314,20 +314,22 @@
<div id="content">
<div class="section" id="concepts">
<h2>Concepts</h2>

<div class="concept entity" id="{{_.ID}}">
{% for row in sets['_']%}
<div class="concept entity" id="{{row.ID}}">
<h3>
{{_.PREFLABEL_EN}}
{{row.PREFLABEL_EN}}
<sup class="sup-op" title="SKOS concept">cc</sup>
</h3>
<table>
<tr>
<th>IRI</th>
<td>
<code>{{vars_dict.baseuri}}/{{vars_dict.relref}}#{{_.ID}}</code>
<code
>{{vars_dict.baseuri}}/{{vars_dict.relref}}#{{row.ID}}</code
>
</td>
</tr>
{%if _.DEFINITION_EN%}
{%if row.DEFINITION_EN%}
<tr>
<th>
<a
Expand All @@ -337,9 +339,9 @@ <h3>
>Description</a
>
</th>
<td><p>{{_.DEFINITION_EN}}</p></td>
<td><p>{{row.DEFINITION_EN}}</p></td>
</tr>
{%endif%} {%if _.ALTLABEL_EN%}
{%endif%} {%if row.ALTLABEL_EN%}
<tr>
<th>
<a
Expand All @@ -349,12 +351,12 @@ <h3>
>Alternative Label</a
>
</th>
<td><p>{{_.ALTLABEL_EN}}</p></td>
<td><p>{{row.ALTLABEL_EN}}</p></td>
</tr>

<tr>
{%endif%} {%if _.BROADER%} {%-set BROADER =
_.BROADER.replace('[','').replace(']','').split(';')%}
{%endif%} {%if row.BROADER%} {%-set BROADER =
row.BROADER.replace('[','').replace(']','').split(';')%}
</tr>

<tr>
Expand All @@ -376,8 +378,8 @@ <h3>
{% endfor %}
</td>
</tr>
{%endif%} {%if _.NARROWER%} {%-set NARROWER =
_.NARROWER.replace('[','').replace(']','').split(';')%}
{%endif%} {%if row.NARROWER%} {%-set NARROWER =
row.NARROWER.replace('[','').replace(']','').split(';')%}
<tr>
<th>
<a
Expand All @@ -400,7 +402,7 @@ <h3>
{%endif%}
</table>
</div>
{% if ctrl.isLast%}
{% endfor %}
</div>
<div id="namespaces">
<h2>Namespaces</h2>
Expand Down Expand Up @@ -501,4 +503,3 @@ <h4>
</div>
</body>
</html>
{% endif %}
34 changes: 19 additions & 15 deletions templates/template_ttl.ttl
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>

<{{vars_dict.baseuri}}/{{vars_dict.relref}}#{{_.ID}}>
{% for row in sets['_']%}
<{{vars_dict.baseuri}}/{{vars_dict.relref}}#{{row.ID}}>
rdf:type skos:Concept ;
dc:date "{{_.DATE}}" ;
dc:identifier "{{_.ID}}" ;
skos:prefLabel "{{_.PREFLABEL_EN}}"@en ;
{%-if '[' in _.BROADER -%}
{%-set BROADER = _.BROADER.replace('[','').replace(']','').split(';')%}
skos:broader {%for B in BROADER%} <{{vars_dict.baseuri}}/{{vars_dict.relref}}#{{B}}> ,{%endfor%};
dc:date "{{row.DATE}}" ;
dc:identifier "{{row.ID}}" ;
skos:prefLabel "{{row.PREFLABEL_EN}}"@en ;
{%-if '[' in row.BROADER -%}
{%-set BROADER = row.BROADER.replace('[','').replace(']','').split(';')%}
skos:broader {% for B in BROADER %} <{{vars_dict.baseuri}}/{{vars_dict.relref}}#{{B}}>{% if not forloop.last %} ,{% endif %}{% endfor %};
{%-endif%}
{%-if '[' in _.NARROWER -%}
{%-set NARROWER = _.NARROWER.replace('[','').replace(']','').split(';')%}
skos:narrower {%for N in NARROWER%} <{{vars_dict.baseuri}}/{{vars_dict.relref}}#{{N}}> ,{%endfor%};
{%-if '[' in row.NARROWER -%}
{%-set NARROWER = row.NARROWER.replace('[','').replace(']','').split(';')%}
skos:narrower {%for N in NARROWER%} <{{vars_dict.baseuri}}/{{vars_dict.relref}}#{{N}}>{% if not forloop.last %} ,{% endif %}{%endfor%};
{%-endif%}
{%if _.DEFINITION_EN-%}
skos:definition "{{_.DEFINITION_EN}}"@en ;
{%if row.DEFINITION_EN-%}
skos:definition "{{row.DEFINITION_EN}}"@en ;
{%-endif%}
{%if _.ALTLABEL_EN-%}
skos:altLabel "{{_.ALTLABEL_EN}}"
{%if row.ALTLABEL_EN-%}
skos:altLabel "{{row.ALTLABEL_EN}}"
{%-endif%}
.

{% endfor %}
4 changes: 4 additions & 0 deletions tests/new_in/emobonOntology.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"ID","DATE","PREFLABEL_EN","DEFINITION_EN","ALTLABEL_EN","BROADER","NARROWER"
1,2024-08-30,"Hard","Hard sample type","hard",,
2,2024-08-30,"Soil","Soil sample type","soil",,
3,2024-08-30,"Water","Water sample type","water",,
2 changes: 1 addition & 1 deletion tests/new_in/onto-one_draft.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ID,DATE,PREFLABEL_EN,DEFINITION_EN,ALTLABEL_EN,BROADER,NARROWER
1,2016-01-01,Abdominal pain,Pain in the region of the abdomen. It is a common complaint and has many causes.,,[4],[2]
2,2017-01-01,Rectum,bodypart that is responsible for excretion of feces,,[4],
2,2017-01-01,Rectum,bodypart that is responsible for the excretion of feces,,[4],
3,2018-01-02,Spine,bodypart most people don't have ,Back,[4],[2]
4,2017-02-28,Body, the physical structure of a person or an animal.,,,[3;2;1]
5,2019-01-31,No Def,,no definition,[4],[2;1]
Expand Down
10 changes: 9 additions & 1 deletion tests/new_out/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ <h3 class="title">



<a href="emobonOntology_vocab" class="myButton" > Vocabulary</a>






Expand Down Expand Up @@ -378,7 +382,9 @@ <h3 class="title">



<a href="onto-one_vocab" class="myButton" ><span class="red">DRAFT</span> Vocabulary</a>


<a href="onto-one_vocab" class="myButton" > Vocabulary</a>



Expand Down Expand Up @@ -430,6 +436,8 @@ <h3 class="title">





<a href="onto-two_vocab" class="myButton" > Vocabulary</a>


Expand Down
12 changes: 1 addition & 11 deletions tests/new_out/onto-one.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,4 @@ tst1:CClass1
rdfs:isDefinedBy <https://example.org/pylode2pages-test/onto-one> ;
rdfs:comment "Concept Class Test for onto-one."@en ;
rdfs:label "ConceptClass#1"@en ;
rdfs:subClassOf dc:Location, skos:Concept .
<https://example.org/pylode2pages-test/onto-one#10>
rdf:type skos:Concept ;
dc:date "2000-01-01" ;
dc:identifier "10" ;
skos:prefLabel "test 2"@en ;
skos:broader <https://example.org/pylode2pages-test/onto-one#7> , <https://example.org/pylode2pages-test/onto-one#8> , <https://example.org/pylode2pages-test/onto-one#9> ,;
skos:narrower <https://example.org/pylode2pages-test/onto-one#1> ,;
skos:definition " second test"@en ;

.
rdfs:subClassOf dc:Location, skos:Concept .
21 changes: 21 additions & 0 deletions tests/test_entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,26 @@ def test_main():
assert_result(baseuri, outfolder, ontos)


def test_vocabs():
enable_test_logging()
log.info(
f"Running tests in {__file__} "
+ "with -v(erbose) and -s(no stdout capturing) "
+ "and logging to stdout, level controlled by env var ${PYTEST_LOGCONF}"
)
parent = Path(__file__).resolve().parent
outfolder = parent / "new_out"
shutil.rmtree(outfolder, ignore_errors=True)
nsfolder = parent / "new_in"

baseuri = "https://example.org/pylode2pages-test"
ontos = ep.publish_ontologies(baseuri, str(nsfolder), str(outfolder), "templates")
vocabs = ep.publish_vocabs(baseuri, str(nsfolder), str(outfolder), "templates")
ep.publish_index_html(
baseuri, str(nsfolder), str(outfolder), "templates", ontos, vocabs
)
log.info(f"ontologies produced == {ontos}")


if __name__ == "__main__":
run_single_test(__file__)

0 comments on commit 26ba20e

Please sign in to comment.