update yaml and implement graph/yaml consistency check. Add local bootstrap assets

This commit is contained in:
Markus Döring 2015-01-13 14:33:37 +01:00
parent ab2da327ee
commit 626b4239b8
8 changed files with 2105 additions and 1961 deletions

5
assets/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

6
assets/bootstrap.min.js vendored Normal file

File diff suppressed because one or more lines are too long

5
assets/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,8 @@
Location:
definition: 'A spatial region or named place.'
comment: ''
details: http://dublincore.org/usage/terms/history/#Location-001
type:
definition: 'The nature or genre of the resource. For Darwin Core, recommended best practice is to use the name of the class that defines the root of the record.'
comment: 'Examples: "StillImage", "MovingImage", "Sound", "PhysicalObject", "Event", "Text". For discussion see http://terms.tdwg.org/wiki/dwc:type'

View File

@ -1 +1 @@
- Record-level Terms: - DC_type - DC_modified - DC_language - DC_license - DC_rightsHolder - DC_accessRights - DC_bibliographicCitation - DC_references - institutionID - collectionID - datasetID - institutionCode - collectionCode - datasetName - ownerInstitutionCode - basisOfRecord - informationWithheld - dataGeneralizations - dynamicProperties - Occurrence: - occurrenceID - catalogNumber - recordNumber - recordedBy - individualCount - sex - lifeStage - reproductiveCondition - behavior - establishmentMeans - occurrenceStatus - preparations - disposition - associatedMedia - associatedReferences - associatedSequences - associatedTaxa - otherCatalogNumbers - occurrenceRemarks - Organism: - organismID - organismName - organismScope - associatedOccurrences - associatedOrganisms - previousIdentifications - organismRemarks - MaterialSample: - materialSampleID - Event: - eventID - fieldNumber - eventDate - eventTime - startDayOfYear - endDayOfYear - year - month - day - verbatimEventDate - habitat - samplingProtocol - samplingEffort - fieldNotes - eventRemarks - DC_Location: - locationID - higherGeographyID - higherGeography - continent - waterBody - islandGroup - island - country - countryCode - stateProvince - county - municipality - locality - verbatimLocality - minimumElevationInMeters - maximumElevationInMeters - verbatimElevation - minimumDepthInMeters - maximumDepthInMeters - verbatimDepth - minimumDistanceAboveSurfaceInMeters - maximumDistanceAboveSurfaceInMeters - locationAccordingTo - locationRemarks - decimalLatitude - decimalLongitude - geodeticDatum - coordinateUncertaintyInMeters - coordinatePrecision - pointRadiusSpatialFit - verbatimCoordinates - verbatimLatitude - verbatimLongitude - verbatimCoordinateSystem - verbatimSRS - footprintWKT - footprintSRS - footprintSpatialFit - georeferencedBy - georeferencedDate - georeferenceProtocol - georeferenceSources - georeferenceVerificationStatus - georeferenceRemarks - GeologicalContext: - geologicalContextID - earliestEonOrLowestEonothem - latestEonOrHighestEonothem - earliestEraOrLowestErathem - latestEraOrHighestErathem - earliestPeriodOrLowestSystem - latestPeriodOrHighestSystem - earliestEpochOrLowestSeries - latestEpochOrHighestSeries - earliestAgeOrLowestStage - latestAgeOrHighestStage - lowestBiostratigraphicZone - highestBiostratigraphicZone - lithostratigraphicTerms - group - formation - member - bed - Identification: - identificationID - identificationQualifier - typeStatus - identifiedBy - dateIdentified - identificationReferences - identificationVerificationStatus - identificationRemarks - Taxon: - taxonID - scientificNameID - acceptedNameUsageID - parentNameUsageID - originalNameUsageID - nameAccordingToID - namePublishedInID - taxonConceptID - scientificName - acceptedNameUsage - parentNameUsage - originalNameUsage - nameAccordingTo - namePublishedIn - namePublishedInYear - higherClassification - kingdom - phylum - class - order - family - genus - subgenus - specificEpithet - infraspecificEpithet - taxonRank - verbatimTaxonRank - scientificNameAuthorship - vernacularName - nomenclaturalCode - taxonomicStatus - nomenclaturalStatus - taxonRemarks - ResourceRelationship: - resourceRelationshipID - resourceID - relatedResourceID - relationshipOfResource - relationshipAccordingTo - relationshipEstablishedDate - relationshipRemarks - MeasurementOrFact: - measurementID - measurementType - measurementValue - measurementAccuracy - measurementUnit - measurementDeterminedBy - measurementDeterminedDate - measurementMethod - measurementRemarks
- Record-level: - DC_type - DC_modified - DC_language - DC_license - DC_rightsHolder - DC_accessRights - DC_bibliographicCitation - DC_references - institutionID - collectionID - datasetID - institutionCode - collectionCode - datasetName - ownerInstitutionCode - basisOfRecord - informationWithheld - dataGeneralizations - dynamicProperties - Occurrence: - occurrenceID - catalogNumber - recordNumber - recordedBy - individualCount - sex - lifeStage - reproductiveCondition - behavior - establishmentMeans - occurrenceStatus - preparations - disposition - associatedMedia - associatedReferences - associatedSequences - associatedTaxa - otherCatalogNumbers - occurrenceRemarks - Organism: - organismID - organismName - organismScope - associatedOccurrences - associatedOrganisms - previousIdentifications - organismRemarks - MaterialSample: - materialSampleID - LivingSpecimen: - PreservedSpecimen: - FossilSpecimen: - Event: - eventID - fieldNumber - eventDate - eventTime - startDayOfYear - endDayOfYear - year - month - day - verbatimEventDate - habitat - samplingProtocol - samplingEffort - fieldNotes - eventRemarks - HumanObservation: - MachineObservation: - DC_Location: - locationID - higherGeographyID - higherGeography - continent - waterBody - islandGroup - island - country - countryCode - stateProvince - county - municipality - locality - verbatimLocality - minimumElevationInMeters - maximumElevationInMeters - verbatimElevation - minimumDepthInMeters - maximumDepthInMeters - verbatimDepth - minimumDistanceAboveSurfaceInMeters - maximumDistanceAboveSurfaceInMeters - locationAccordingTo - locationRemarks - decimalLatitude - decimalLongitude - geodeticDatum - coordinateUncertaintyInMeters - coordinatePrecision - pointRadiusSpatialFit - verbatimCoordinates - verbatimLatitude - verbatimLongitude - verbatimCoordinateSystem - verbatimSRS - footprintWKT - footprintSRS - footprintSpatialFit - georeferencedBy - georeferencedDate - georeferenceProtocol - georeferenceSources - georeferenceVerificationStatus - georeferenceRemarks - GeologicalContext: - geologicalContextID - earliestEonOrLowestEonothem - latestEonOrHighestEonothem - earliestEraOrLowestErathem - latestEraOrHighestErathem - earliestPeriodOrLowestSystem - latestPeriodOrHighestSystem - earliestEpochOrLowestSeries - latestEpochOrHighestSeries - earliestAgeOrLowestStage - latestAgeOrHighestStage - lowestBiostratigraphicZone - highestBiostratigraphicZone - lithostratigraphicTerms - group - formation - member - bed - Identification: - identificationID - identificationQualifier - typeStatus - identifiedBy - dateIdentified - identificationReferences - identificationVerificationStatus - identificationRemarks - Taxon: - taxonID - scientificNameID - acceptedNameUsageID - parentNameUsageID - originalNameUsageID - nameAccordingToID - namePublishedInID - taxonConceptID - scientificName - acceptedNameUsage - parentNameUsage - originalNameUsage - nameAccordingTo - namePublishedIn - namePublishedInYear - higherClassification - kingdom - phylum - class - order - family - genus - subgenus - specificEpithet - infraspecificEpithet - taxonRank - verbatimTaxonRank - scientificNameAuthorship - vernacularName - nomenclaturalCode - taxonomicStatus - nomenclaturalStatus - taxonRemarks - ResourceRelationship: - resourceRelationshipID - resourceID - relatedResourceID - relationshipOfResource - relationshipAccordingTo - relationshipEstablishedDate - relationshipRemarks - MeasurementOrFact: - measurementID - measurementType - measurementValue - measurementAccuracy - measurementUnit - measurementDeterminedBy - measurementDeterminedDate - measurementMethod - measurementRemarks

View File

@ -20,7 +20,7 @@
<meta name="DC.license" content="http://creativecommons.org/licenses/by/4.0/legalcode">
<meta name="DC.language" content="en">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../assets/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../assets/main.css">
</head>
@ -69,7 +69,7 @@
<nav class="col-sm-2 terms-sidebar">
<ul class="nav nav-stacked">
#for $group in $groups
<li><a href="#$group.name">$group.name</a></li>
<li><a href="#$group.name_simple">$group.name</a></li>
#end for
</ul>
</nav>
@ -79,34 +79,34 @@
<p>This page provides a list of all currently recommended terms of the Darwin Core standard and their definitions. Terms that begin with <code>dcterms:</code> are from the <a href="http://dublincore.org/documents/dcmi-terms/">Dublin Core</a>. Categories correspond to Darwin Core classes (terms that have other terms to describe them). List of these terms in various formats can be found in <a href="../downloads">downloads</a>.</p>
</div>
#def showTerm($t, $isProperty)
#if $t.uri is not None
#if $isProperty
<dl id="$t.name" class="dl-horizontal term-dl">
#else
<dl class="dl-horizontal class-dl">
#end if
<dt>Name</dt><dd>$t.name</dd>
<dt>Label</dt><dd>$t.label</dd>
<dt>Identifier</dt><dd><a href="$t.uri">$t.uri</a></dd>
#if $isProperty
<dt>Class</dt><dd>$t.class</dd>
#end if
<dt>Definition</dt><dd>$t.definition</dd>
<dt>Comment</dt><dd>$t.comment</dd>
<dt>Reference</dt><dd><a href="http://terms.tdwg.org/wiki/$t.fullname">http://terms.tdwg.org/wiki/$t.fullname</a></dd>
<dt>History</dt><dd><a href="$t.version">$t.version</a></dd>
</dl>
#end if
#end def
#def showTerm($t, $isProperty)
#if $t.uri is not None
#if $isProperty
<dl id="$t.name_simple" class="dl-horizontal term-dl">
#else
<dl class="dl-horizontal class-dl">
#end if
<dt>Name</dt><dd>$t.name</dd>
<dt>Label</dt><dd>$t.label</dd>
<dt>Identifier</dt><dd><a href="$t.uri">$t.uri</a></dd>
#if $isProperty
<dt>Class</dt><dd>$t.class</dd>
#end if
<dt>Definition</dt><dd>$t.definition</dd>
<dt>Comment</dt><dd>$t.comment</dd>
<dt>Reference</dt><dd><a href="http://terms.tdwg.org/wiki/$t.name_prefixed">http://terms.tdwg.org/wiki/$t.name_prefixed</a></dd>
<dt>History</dt><dd><a href="$t.version">$t.version</a></dd>
</dl>
#end if
#end def
#for $group in $groups
<section id="$group.name" class="class-section">
<section id="$group.name_simple" class="class-section">
<header class="well">
<h2>$group.name</h2>
<ul class="list-inline term-index">
#for $term in $group.terms
<li><a href="#$term.name">$term.name</a></li>
<li><a href="#$term.name_simple">$term.name</a></li>
#end for
</ul>
</header>
@ -130,8 +130,8 @@
</footer>
<!-- Scripts -->
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../assets/jquery.min.js"></script>
<script type="text/javascript" src="../assets/bootstrap.min.js"></script>
<script type="text/javascript">
\$("body").scrollspy({
target: ".terms-sidebar",

View File

@ -13,6 +13,8 @@ from rdflib.namespace import RDFS
DWC=Namespace("http://rs.tdwg.org/dwc/terms/")
DC=Namespace("http://purl.org/dc/terms/")
DWCA=Namespace("http://rs.tdwg.org/dwc/terms/attributes/")
REC_LEVEL=DWC.term("Record-level")
def buildHtml():
data=parseTerms()
@ -26,60 +28,81 @@ def buildDownloads():
print """building downloads"""
print """TBD"""
def veriyfCompleteness(graph, yaml):
print """veriyf graph completeness"""
print """TBD"""
def anchorLinks(x):
print """TBD"""
def getTermDef(name, g):
t={}
t["name"]=name
t["fullname"]="dwc:"+name
if name.startswith("DC_"):
name=name[3:]
uri=DC[name]
t["name"]="dcterms:"+name
t["name_simple"]=name
t["name_prefixed"]=t["name"]
t["fullname"]=t["name"]
elif name.find(" ") > 0:
uri=None
uri=DC.term(name)
else:
uri=DWC[name]
t["name"]=name
t["name_simple"]=name
t["name_prefixed"]="dwc:"+name
uri=DWC.term(name)
if uri==REC_LEVEL:
uri=None
t["uri"]=uri
t["label"]=g.value(subject=uri, predicate=RDFS.label)
t["class"]=g.value(subject=uri, predicate=DWCA.organizedInClass)
t["definition"]=g.value(subject=uri, predicate=RDFS.comment)
t["comment"]=g.value(subject=uri, predicate=DC.description)
t["version"]=g.value(subject=uri, predicate=DC.hasVersion)
if uri is not None:
t["label"]=g.value(subject=uri, predicate=RDFS.label)
t["class"]=g.value(subject=uri, predicate=DWCA.organizedInClass)
t["definition"]=g.value(subject=uri, predicate=RDFS.comment)
t["comment"]=g.value(subject=uri, predicate=DC.description)
t["version"]=g.value(subject=uri, predicate=DC.hasVersion)
if t["definition"] is None:
raise AssertionError("Unknown term definition "+str(uri))
return t
def parseTerms():
with open('term_order.yaml', 'r') as f:
order = yaml.load(f)
with open('dc.yaml', 'r') as dcf:
dc = yaml.load(dcf)
g = Graph()
g.parse("../terms/dwc_normative.rdf")
# we remove the abstract dwc term accordingTo
g.remove((DWC.accordingTo,None,None))
g.remove((DWC+"",None,None))
if (DWC+"", None, None) in g:
raise AssertionError("DWC NS in here")
with open('dc.yaml', 'r') as dcf:
dc = yaml.load(dcf)
for t in dc:
uri=DC[t]
g.add( (uri, RDFS.comment, Literal(dc[t]["definition"])) )
g.add( (uri, DC.description, Literal(dc[t]["comment"])) )
g.add( (uri, DC.hasVersion, URIRef(dc[t]["details"])) )
# before we continue verify we have all terms covered in both the order yaml and the graph
veriyfCompleteness(g, order)
with open('term_order.yaml', 'r') as f:
terms = yaml.load(f)
data={}
groups=[]
for groupData in order:
group=getTermDef(sorted(groupData.keys())[0], g)
groups.append(group)
group["terms"]=[]
for t in sorted(groupData.values())[0]:
group["terms"].append(getTermDef(t, g))
for group in terms:
groupTerm=getTermDef(sorted(group.keys())[0], g)
groupTerm["terms"]=[]
if group.values() is not None and sorted(group.values())[0] is not None:
for t in sorted(group.values())[0]:
groupTerm["terms"].append(getTermDef(t, g))
groups.append(groupTerm)
data["groups"]=groups
# finally verify we have all terms covered in both the order yaml and the graph
verifyCompleteness(g, groups)
return data
def verifyCompleteness(graph, groups):
terms={}
for g in groups:
if "uri" in g:
terms[str(g["uri"])]=1
for t in g["terms"]:
terms[str(t["uri"])]=1
print """%s terms defined""" % len(terms)
for s in graph.subjects():
if s not in (DWC.accordingTo, DWC.term("")) and str(s) not in terms:
raise AssertionError("Term missing from terms_order.yaml: "+s)
print """All terms exist in both the graph and yaml"""
if __name__ == "__main__":

File diff suppressed because it is too large Load Diff