Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Commit

Permalink
Adding equivalences.
Browse files Browse the repository at this point in the history
  • Loading branch information
leth committed Jul 27, 2010
1 parent 3ecd722 commit 078594f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions libvocab.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,33 @@ def termlist(self):
if contentStr != "":
isDisjointWith = "%s <td> %s </td></tr>" % (startStr, contentStr)

# equivalent to

isEquivalentTo = ''

qq = [
'SELECT ?eq ?l WHERE { <%s> <http://www.w3.org/2002/07/owl#equivalentClass> ?eq . OPTIONAL { ?eq rdfs:label ?l } . FILTER (! isBLANK(?eq)) } ' % (term.uri),
'SELECT ?eq ?l WHERE { ?eq <http://www.w3.org/2002/07/owl#equivalentClass> <%s> . OPTIONAL { ?eq rdfs:label ?l } . FILTER (! isBLANK(?eq)) } ' % (term.uri)
]

startStr = '<tr><th>Equivalent To</th>\n'
contentStr = ''
for (q) in qq:
relations = g.query(q)

for (equivalentTo, label) in relations:
equiv = Term(equivalentTo)

if (equiv.is_external(self.vocab)):
if (label == None):
label = self.vocab.niceName(equiv.uri)
termStr = """<span rel="owl:equivalentClass" href="%s"><a href="%s">%s</a></span>\n""" % (equivalentTo, equivalentTo, label)
else:
termStr = """<span rel="owl:equivalentClass" href="%s"><a href="#term_%s">%s</a></span>\n""" % (equivalentTo, equiv.id, label)
contentStr = "%s %s" % (contentStr, termStr)

if contentStr != "":
isEquivalentTo = "%s <td> %s </td></tr>" % (startStr, contentStr)
# end

dn = os.path.join(self.basedir, "doc")
Expand Down

0 comments on commit 078594f

Please sign in to comment.