Skip to content

Commit

Permalink
Merge pull request #28 from ResearchObject/rm_rocrate_ctx
Browse files Browse the repository at this point in the history
Remove reference to RO-Crate context from the JSON(LD) files
  • Loading branch information
simleo authored Jul 22, 2024
2 parents 2e0f58e + 7429de8 commit 5c7a33b
Show file tree
Hide file tree
Showing 24 changed files with 534 additions and 599 deletions.
10 changes: 5 additions & 5 deletions context.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[
"https://w3id.org/ro/crate/1.1/context",
{
{
"@context": {
"Person": "https://w3id.org/ro/terms/#Person",
"fullName": "https://w3id.org/ro/terms/#fullName",
"friend_of": "https://w3id.org/ro/terms/#friend_of"
"friend_of": "https://w3id.org/ro/terms/#friend_of",
"sdConformsTo": "https://w3id.org/ro/terms/#sdConformsTo"
}
]
}
10 changes: 5 additions & 5 deletions context.jsonld
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[
"https://w3id.org/ro/crate/1.1/context",
{
{
"@context": {
"Person": "https://w3id.org/ro/terms/#Person",
"fullName": "https://w3id.org/ro/terms/#fullName",
"friend_of": "https://w3id.org/ro/terms/#friend_of"
"friend_of": "https://w3id.org/ro/terms/#friend_of",
"sdConformsTo": "https://w3id.org/ro/terms/#sdConformsTo"
}
]
}
5 changes: 1 addition & 4 deletions copo/context.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"@context": [
"https://w3id.org/ro/crate/1.1/context",
{
"@context": {
"associated_tol_project": "https://w3id.org/ro/terms/copo#associated_tol_project",
"biosampleAccession": "https://w3id.org/ro/terms/copo#biosampleAccession",
"boldAccession": "https://w3id.org/ro/terms/copo#boldAccession",
Expand Down Expand Up @@ -90,5 +88,4 @@
"VOUCHER_INSTITUTION": "https://w3id.org/ro/terms/sample#VOUCHER_INSTITUTION",
"OTHER_INFORMATION": "https://w3id.org/ro/terms/sample#OTHER_INFORMATION"
}
]
}
5 changes: 1 addition & 4 deletions copo/context.jsonld
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"@context": [
"https://w3id.org/ro/crate/1.1/context",
{
"@context": {
"associated_tol_project": "https://w3id.org/ro/terms/copo#associated_tol_project",
"biosampleAccession": "https://w3id.org/ro/terms/copo#biosampleAccession",
"boldAccession": "https://w3id.org/ro/terms/copo#boldAccession",
Expand Down Expand Up @@ -90,5 +88,4 @@
"VOUCHER_INSTITUTION": "https://w3id.org/ro/terms/sample#VOUCHER_INSTITUTION",
"OTHER_INFORMATION": "https://w3id.org/ro/terms/sample#OTHER_INFORMATION"
}
]
}
13 changes: 5 additions & 8 deletions criminalcharacters/context.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"@context": [
"https://w3id.org/ro/crate/1.1/context",
{
"education": "https://w3id.org/ro/terms/criminalcharacters#education",
"interests": "https://w3id.org/ro/terms/criminalcharacters#interests",
"Person": "https://w3id.org/ro/terms/criminalcharacters#Person"
}
]
"@context": {
"education": "https://w3id.org/ro/terms/criminalcharacters#education",
"interests": "https://w3id.org/ro/terms/criminalcharacters#interests",
"Person": "https://w3id.org/ro/terms/criminalcharacters#Person"
}
}
13 changes: 5 additions & 8 deletions criminalcharacters/context.jsonld
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"@context": [
"https://w3id.org/ro/crate/1.1/context",
{
"education": "https://w3id.org/ro/terms/criminalcharacters#education",
"interests": "https://w3id.org/ro/terms/criminalcharacters#interests",
"Person": "https://w3id.org/ro/terms/criminalcharacters#Person"
}
]
"@context": {
"education": "https://w3id.org/ro/terms/criminalcharacters#education",
"interests": "https://w3id.org/ro/terms/criminalcharacters#interests",
"Person": "https://w3id.org/ro/terms/criminalcharacters#Person"
}
}
11 changes: 4 additions & 7 deletions example/context.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"@context": [
"https://w3id.org/ro/crate/1.1/context",
{
"Book": "https://w3id.org/ro/terms/example#Book",
"title": "https://w3id.org/ro/terms/example#title"
}
]
"@context": {
"Book": "https://w3id.org/ro/terms/example#Book",
"title": "https://w3id.org/ro/terms/example#title"
}
}
11 changes: 4 additions & 7 deletions example/context.jsonld
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"@context": [
"https://w3id.org/ro/crate/1.1/context",
{
"Book": "https://w3id.org/ro/terms/example#Book",
"title": "https://w3id.org/ro/terms/example#title"
}
]
"@context": {
"Book": "https://w3id.org/ro/terms/example#Book",
"title": "https://w3id.org/ro/terms/example#title"
}
}
20 changes: 9 additions & 11 deletions gen_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
from pathlib import Path


RO_CRATE_VERSION = "1.1"
RO_TERMS_PREFIX = "https://w3id.org/ro/terms"
VOCAB_FN = "vocabulary.csv"


def build_context(namespace, vocab_path, ro_crate_version=RO_CRATE_VERSION):
ro_crate_context = f"https://w3id.org/ro/crate/{ro_crate_version}/context"
def build_context(namespace, vocab_path):
add_terms = {}
with open(vocab_path, newline="") as f:
reader = csv.DictReader(f)
Expand All @@ -26,26 +24,26 @@ def build_context(namespace, vocab_path, ro_crate_version=RO_CRATE_VERSION):
if not k:
continue # empty line!
add_terms[k] = f"{RO_TERMS_PREFIX}/{namespace}#{k}"
return {"@context": [ro_crate_context, add_terms]}
return {"@context": add_terms}


def main(args):
ns_dir = Path(args.ns_dir)
vocab_path = ns_dir / VOCAB_FN
if not vocab_path.is_file():
raise RuntimeError(f"{vocab_path} not found")
context = build_context(ns_dir.name, vocab_path,
ro_crate_version=args.ro_crate_version)
context = build_context(ns_dir.name, vocab_path)
if not args.output:
args.output = ns_dir / "context.jsonld"
with open(args.output, "wt", encoding="utf8") as f:
json.dump(context, f, ensure_ascii=False, indent=4, sort_keys=False)
args.output = [ns_dir / f"context.{ext}" for ext in ("json", "jsonld")]
else:
args.output = [args.output]
for out_fn in args.output:
with open(out_fn, "wt", encoding="utf8") as f:
json.dump(context, f, ensure_ascii=False, indent=4, sort_keys=False)


if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("ns_dir", metavar="NAMESPACE", help="namespace dir")
parser.add_argument("-v", "--ro-crate-version", metavar="string",
default=RO_CRATE_VERSION, help="RO-Crate version")
parser.add_argument('-o', '--output', metavar="FILE")
main(parser.parse_args(sys.argv[1:]))
25 changes: 11 additions & 14 deletions ods/context.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
{
"@context": [
"https://w3id.org/ro/crate/1.1/context",
{
"Specimen": "https://w3id.org/ro/terms/ods#Specimen",
"SpecimenRecord": "https://w3id.org/ro/terms/ods#SpecimenRecord",
"authoritative": "https://w3id.org/ro/terms/ods#authoritative",
"modified": "https://w3id.org/ro/terms/ods#modified",
"midsLevel": "https://w3id.org/ro/terms/ods#midsLevel",
"physicalSpecimenId": "https://w3id.org/ro/terms/ods#physicalSpecimenId",
"institution": "https://w3id.org/ro/terms/ods#institution",
"materialType": "https://w3id.org/ro/terms/ods#materialType",
"name": "https://w3id.org/ro/terms/ods#name"
}
]
"@context": {
"Specimen": "https://w3id.org/ro/terms/ods#Specimen",
"SpecimenRecord": "https://w3id.org/ro/terms/ods#SpecimenRecord",
"authoritative": "https://w3id.org/ro/terms/ods#authoritative",
"modified": "https://w3id.org/ro/terms/ods#modified",
"midsLevel": "https://w3id.org/ro/terms/ods#midsLevel",
"physicalSpecimenId": "https://w3id.org/ro/terms/ods#physicalSpecimenId",
"institution": "https://w3id.org/ro/terms/ods#institution",
"materialType": "https://w3id.org/ro/terms/ods#materialType",
"name": "https://w3id.org/ro/terms/ods#name"
}
}
25 changes: 11 additions & 14 deletions ods/context.jsonld
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
{
"@context": [
"https://w3id.org/ro/crate/1.1/context",
{
"Specimen": "https://w3id.org/ro/terms/ods#Specimen",
"SpecimenRecord": "https://w3id.org/ro/terms/ods#SpecimenRecord",
"authoritative": "https://w3id.org/ro/terms/ods#authoritative",
"modified": "https://w3id.org/ro/terms/ods#modified",
"midsLevel": "https://w3id.org/ro/terms/ods#midsLevel",
"physicalSpecimenId": "https://w3id.org/ro/terms/ods#physicalSpecimenId",
"institution": "https://w3id.org/ro/terms/ods#institution",
"materialType": "https://w3id.org/ro/terms/ods#materialType",
"name": "https://w3id.org/ro/terms/ods#name"
}
]
"@context": {
"Specimen": "https://w3id.org/ro/terms/ods#Specimen",
"SpecimenRecord": "https://w3id.org/ro/terms/ods#SpecimenRecord",
"authoritative": "https://w3id.org/ro/terms/ods#authoritative",
"modified": "https://w3id.org/ro/terms/ods#modified",
"midsLevel": "https://w3id.org/ro/terms/ods#midsLevel",
"physicalSpecimenId": "https://w3id.org/ro/terms/ods#physicalSpecimenId",
"institution": "https://w3id.org/ro/terms/ods#institution",
"materialType": "https://w3id.org/ro/terms/ods#materialType",
"name": "https://w3id.org/ro/terms/ods#name"
}
}
Loading

0 comments on commit 5c7a33b

Please sign in to comment.