diff options
Diffstat (limited to 'template.py')
-rw-r--r-- | template.py | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/template.py b/template.py new file mode 100644 index 0000000..e2a1a39 --- /dev/null +++ b/template.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python +# Example quickstart template for designing new ontologies + +from sys import argv +#from genshi.input import XML + +from ontologygen import Property, Class, Example, Ontology, Ontologies + +BASE = 'http://purl.org/net/foo' + + +# +# classes +# + + +# v0.1 + +class Foo(Class): + """abstract foo item, use only its subclasses""" + + +class TFoo(Foo): + """T-shaped foo + + Represents foos that are special because of the T-shape. + """ + +# +# properties +# + +# v0.1 + +@Foo.inDomainOf +class bar(Property): + """plain bar + + Connects resources with foos. + """ + range = "http://www.w3.org/2001/XMLSchema#string" + + +class baz(bar): + """bar specialization known as baz""" + + +# +# examples +# + +# v0.1 + +class ex_0_1_schema(Example): + """Illustrative figure of the vocabulary.""" + image = '0.2.svg' + + +class ex_0_1(Example): + """An example snippet. + +<foo:tfoo about="#mytfoo"> + <foo:baz>test</foo:baz> +</foo:tfoo> + """ + pfx = 'foo:' + + +# +# ontology + versions +# + + +ontologies = Ontologies() + + +class foo(Ontology): + """Descriptive vocabulary for foos + + This vocabulary serves a purpose of shedding light into semantics + in the field of foos. + """ + base_uri = BASE + #creator = XML('''\ + # <dc:foo xmlns:dc="http://purl.org/dc/elements/1.1/" + # >John Doe</dc:foo>''') + creator = 'John Doe' + + +@ontologies.include +class foo_0_1(foo): + version = '0.1' + issued = '2013-02-19' + modified = '2013-03-20' + classes = [ + Foo, + TFoo, + ] + properties = [ + bar, + baz, + ] + examples = [ + ex_0_1_schema, + ex_0_1, + ] + + +#@ontologies.include +#@foo_0_1.supersededBy +#class foo_0_2(foo): +# ... + + +if __name__ == '__main__': + ontologies.generate_latest(**(len(argv) > 1 and {'outfile': argv[1]} or {})) |