File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 6868 - sparql-update
6969 - json-ld-frame
7070 - jq
71+ - semantic-uplift
7172 - description : Other identifiers are also accepted
7273 $ref : ' #/$defs/nonEmptyString'
7374
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+ import json
3+ from typing import AnyStr
4+
5+ from ogc .na .util import load_yaml
6+ from rdflib import Graph
7+
8+ from ogc .bblocks .models import TransformMetadata , Transformer
9+ from ogc .na import ingest_json
10+
11+ transform_type = 'semantic-uplift'
12+
13+ default_inputs = [
14+ 'application/json' ,
15+ ]
16+
17+ default_outputs = [
18+ 'text/turtle' ,
19+ 'rdf/xml' ,
20+ ]
21+
22+ class SemanticUpliftTransformer (Transformer ):
23+
24+ def __init__ (self ):
25+ super ().__init__ ([transform_type ], default_inputs , default_outputs )
26+
27+ def do_transform (self , metadata : TransformMetadata ) -> AnyStr | None :
28+ uplift_def = load_yaml (content = metadata .transform_content )
29+ uplifted = json .dumps (ingest_json .uplift_json (json .loads (metadata .input_data ), uplift_def ))
30+ data_graph = Graph ().parse (data = uplifted , format = 'json-ld' )
31+ return data_graph .serialize (format = metadata .target_mime_type )
You can’t perform that action at this time.
0 commit comments