[Python-modules-commits] [python-pyld] 108/276: Give precedence to @vocab over CURIEs when compacting IRIs.
Wolfgang Borgert
debacle at moszumanska.debian.org
Wed Oct 8 23:47:59 UTC 2014
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to branch master
in repository python-pyld.
commit 683681c6fd281439177f7219b3e5f41bfcce1cf0
Author: Dave Longley <dlongley at digitalbazaar.com>
Date: Thu Apr 4 11:36:57 2013 -0400
Give precedence to @vocab over CURIEs when compacting IRIs.
---
lib/pyld/jsonld.py | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py
index 23c2bf4..2c4d99e 100644
--- a/lib/pyld/jsonld.py
+++ b/lib/pyld/jsonld.py
@@ -3218,7 +3218,18 @@ class JsonLdProcessor:
if term is not None:
return term
- # no term match, check for possible CURIEs
+ # no term match, use @vocab if available
+ if vocab:
+ if '@vocab' in active_ctx:
+ vocab_ = active_ctx['@vocab']
+ if iri.startswith(vocab_) and iri != vocab_:
+ # use suffix as relative iri if it is not a term in the
+ # active context
+ suffix = iri[len(vocab_):]
+ if suffix not in active_ctx['mappings']:
+ return suffix
+
+ # no term or @vocab match, check for possible CURIEs
candidate = None
for term, definition in active_ctx['mappings'].items():
# skip terms with colons, they can't be prefixes
@@ -3249,18 +3260,8 @@ class JsonLdProcessor:
if candidate is not None:
return candidate
- # no matching terms or curies, use @vocab if available
- if vocab:
- if '@vocab' in active_ctx:
- vocab_ = active_ctx['@vocab']
- if iri.startswith(vocab_) and iri != vocab_:
- # use suffix as relative iri if it is not a term in the
- # active context
- suffix = iri[len(vocab_):]
- if suffix not in active_ctx['mappings']:
- return suffix
# compact IRI relative to base
- else:
+ if not vocab:
return remove_base(active_ctx['@base'], iri)
# return IRI as is
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-pyld.git
More information about the Python-modules-commits
mailing list