source: CMIP6dreqbuild/trunk/src/framework/dreqPy/makettl.py @ 1029

Subversion URL: http://proj.badc.rl.ac.uk/svn/exarch/CMIP6dreqbuild/trunk/src/framework/dreqPy/makettl.py@1029
Revision 1029, 3.2 KB checked in by mjuckes, 3 years ago (diff)

fixed expts

Line 
1@prefix xs:    <http://www.w3.org/2001/XMLSchema#> .
2@prefix dc:    <http://purl.org/dc/terms/> .
3
4dqc:section a rdf:Class ;
5     rdfs:subClassOf skos:ConceptScheme ;
6     dqc:definition  "Concepts are organised into sections, each of which is associated with a common set of attributes."@en ;
7     dqc:label "Section"@en . 
8
9dqc:coreAttribute  a      dqc:section ;
10        skos:definition  "A core attribute of the Data Request Schema"@en ;
11        skos:prefLabel   "coreAttribute"@en .
12
13dqc:attribute  a      dqc:section ;
14        skos:definition  "A attribute of the Data Request Schema"@en ;
15        skos:prefLabel   "attribute"@en .
16
17dqc:inSection a rdfs:Property ;
18     rdfs:subClassOf skos:inScheme ;
19     dqc:definition  "The inSection property links each concept to a section."@en ;
20     dqc:label "inSection property"@en .
21
22dqc:concept a rdf:Class ;
23     rdfs:subClassOf skos:Concept ;
24     dqc:definition  "Each concept has a specific set of attributes which varies from section to section."@en ;
25     dqc:label "Section"@en . 
26
27dqc:varConcept a rdf:Class ;
28     rdfs:subClassOf dqc:Concept ;
29     dqc:definition  "Variables ...."@en ;
30     dqc:label "Variable Section"@en . 
31"""
32###
33### varConcept has some required properties ..... should be able to specify this in owl or rdfs
34###
35
36##
37## want to place each term with concept scheme associated with a section.
38exampleConceptScheme = """gcos:ECVConceptScheme
39        a                   skos:ConceptScheme ;
40        dc:date             "2015-11-09 14:59:46" ;
41        skos:definition     "Concepts used within GCOS"@en ;
42        skos:hasTopConcept  gcos:atmospheric , gcos:terrestrial , gcos:oceanic ;
43        skos:prefLabel      "A SKOS Concept Scheme for GCOS ECV"@en ."""
44
45ttlRecHead = """
46dqc:%s  a      rdf:Property ;
47"""
48ttlInSect = """   dqc:inSection  dqc:%s ;
49"""
50
51
52def ttlid( u ):
53  return string.replace( u, ':', '_' )
54
55al = ['uid', 'title', 'techNote', 'label', 'superclass', 'useClass', 'type', 'description']
56import dreq
57dq = dreq.loadDreq()
58oo = open( 't1.ttl', 'w' )
59oo.write( header )
60for i in dq.coll['__core__'].items:
61  oo.write( ttlRecHead % ttlid( i.uid ) )
62  oo.write( ttlInSect % ttlid( i._h.uid ) )
63  ll = []
64  for a in al:
65    txt = i.__dict__[a]
66    if txt[:3] == 'xs:' or txt[:4] == 'rdf:':
67      pass
68    else:
69      txt = '"%s"' % string.strip( txt, '"' )
70    ll.append( 'dqc:%s %s' % (a,txt) )
71  oo.write( string.join( ll, ' ;\n' ) + ' . \n' )
72
73for i in dq.coll['__main__'].items:
74  oo.write( ttlRecHead % ttlid( i.uid ) )
75  oo.write( ttlInSect % ttlid( i._h.uid ) )
76  ll = []
77  for a in al:
78    txt = i.__dict__[a]
79    if txt != None:
80      if txt[:3] == 'xs:':
81        pass
82      else:
83        txt = '"%s"' % string.strip( txt, '"' )
84      ll.append( 'dqc:%s %s' % (a,txt) )
85  oo.write( string.join( ll, ' ;\n' ) + ' . \n' )
86
87al = dq.coll['__sect__'].attDefn.keys()
88for i in dq.coll['__sect__'].items:
89  oo.write( ttlRecHead % ttlid( i.uid ) )
90  oo.write( ttlInSect % ttlid( i._h.uid ) )
91  ll = []
92  for a in al:
93    txt = i.__dict__[a]
94    if txt != None:
95      if txt[:3] == 'xs:':
96        pass
97      else:
98        txt = '"%s"' % string.strip( txt, '"' )
99      ll.append( 'dqc:%s %s' % (a,txt) )
100  oo.write( string.join( ll, ' ;\n' ) + ' . \n' )
101
102oo.close()
Note: See TracBrowser for help on using the repository browser.