Commit 185e62d2 authored by Andrei Popescu's avatar Andrei Popescu
Browse files

update traverse.ts and test on a minecraft schema

parent 9b976373
Pipeline #56425 passed with stage
in 21 seconds
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$comment": "https://minecraft.fandom.com/wiki/Custom_dimension#Dimension_type",
"title": "Minecraft Data Pack Dimension Type",
"description": "Configuration file defining a dimension type for a data pack for Minecraft.",
"type": "object",
"properties": {
"name": {
"title": "Name",
"description": "The resource location used for the dimension type.",
"type": "string"
},
"ultrawarm": {
"title": "Ultrawarm",
"description": "Whether the dimensions behaves like the nether (water evaporates and sponges dry) or not. Also lets stalactites drip lava and causes lava to spread faster and thinner.",
"type": "boolean"
},
"natural": {
"title": "Natural",
"description": "When true, nether portals can spawn zombified piglins. When false, compasses spin randomly, and using a bed to set the respawn point or sleep, is disabled.",
"type": "boolean"
},
"coordinate_scale": {
"title": "Coordinate Scale",
"description": "The multiplier applied to coordinates when traveling to the dimension.",
"type": "number"
},
"has_skylight": {
"title": "Has Skylight",
"description": "Whether the dimension has skylight access or not.",
"type": "boolean"
},
"has_ceiling": {
"title": "Has Ceiling",
"description": "Whether the dimension has a bedrock ceiling or not.",
"type": "boolean"
},
"ambient_light": {
"title": "Ambient Light",
"description": "How much light the dimension has.",
"type": "number",
"default": 0.5
},
"fixed_time": {
"title": "Fixed Time",
"description": "If this is set to a number, the time of the day is the specified value.",
"anyOf": [
{
"type": "boolean",
"default": false
},
{
"type": "integer",
"minimum": 0,
"maximum": 24000
}
]
},
"piglin_safe": {
"title": "Piglin Safe",
"description": "Whether piglins shake and transform to zombified piglins.",
"type": "boolean"
},
"bed_works": {
"title": "Bed Words",
"description": "When false, the bed blows up when trying to sleep.",
"type": "boolean"
},
"respawn_anchor_works": {
"title": "Respawn Anchor Works",
"description": "Whether players can charge and use respawn anchors.",
"type": "boolean"
},
"has_raids": {
"title": "Has Raids",
"description": "Whether players with the Bad Omen effect can cause a raid.",
"type": "boolean"
},
"logical_height": {
"title": "Logical Height",
"description": "The maximum height to which chorus fruits and nether portals can bring players within this dimension. This excludes portals that were already built above the limit as they still connect normally.",
"type": "integer"
},
"min_y": {
"title": "Minimum Y",
"description": "The minimum height in which blocks can exist within this dimension.",
"type": "integer",
"minimum": -2032,
"maximum": 2031,
"multipleOf": 16
},
"height": {
"title": "Height",
"description": "The total height in which blocks can exist within this dimension.",
"type": "integer",
"minimum": 0,
"maximum": 4096,
"multipleOf": 16
},
"infiniburn": {
"title": "Infiniburn",
"description": "A resource location defining what block tag to use for infiniburn.",
"type": "string"
},
"effects": {
"title": "Effects",
"description": "Determines the dimension effect used for this dimension.",
"type": "string",
"enum": [
"minecraft:overworld",
"minecraft:the_nether",
"minecraft:the_end"
],
"default": "minecraft:overworld"
}
}
}
\ No newline at end of file
......@@ -15,9 +15,20 @@
@prefix vso: <http://purl.org/vso/ns#>.
@prefix dbpedia-owl: <http://dbpedia.org/ontology/>.
<sdm:rental_methods> owl:oneOf (<key> <creditcard> <paypass> <applepay> <androidpay> <transitcard> <accountnumber> <phone>).
<sdm:station_area> rdfs:hasProperty (<type> <coordinates>).
<sdm:rental_uris> rdfs:hasProperty (<android> <ios> <web>).
<sdm:stations> rdfs:hasProperty (<station_id> <name> <short_name> <lat> <lon> <address> <cross_street> <region_id> <post_code> <rental_methods> <is_virtual_station> <station_area> <capacity> <vehicle_capacity> <is_valet_station> <is_charging_station> <rental_uris> <vehicle_type_capacity>).
<sdm:data> rdfs:hasProperty (<stations>).
<sdm:schema> rdfs:hasProperty (<last_updated> <ttl> <version> <data>).
<name> rdfs:range xsd:string.
<ultrawarm> rdfs:range xsd:boolean.
<natural> rdfs:range xsd:boolean.
<coordinate_scale> rdfs:range xsd:integer.
<has_skylight> rdfs:range xsd:boolean.
<has_ceiling> rdfs:range xsd:boolean.
<ambient_light> rdfs:range xsd:integer.
<piglin_safe> rdfs:range xsd:boolean.
<bed_works> rdfs:range xsd:boolean.
<respawn_anchor_works> rdfs:range xsd:boolean.
<has_raids> rdfs:range xsd:boolean.
<logical_height> rdfs:range xsd:integer.
<min_y> rdfs:range xsd:integer.
<height> rdfs:range xsd:integer.
<infiniburn> rdfs:range xsd:string.
<effects> rdfs:range xsd:string.
<sdm:schema> rdfs:hasProperty (<name> <ultrawarm> <natural> <coordinate_scale> <has_skylight> <has_ceiling> <ambient_light> <fixed_time> <piglin_safe> <bed_works> <respawn_anchor_works> <has_raids> <logical_height> <min_y> <height> <infiniburn> <effects>).
......@@ -27,18 +27,6 @@
"gbfs:Pricing_plan_ids": "pricing_plan_ids"
},
"sources": {
"./GBFS/station_information.json": "gbfs:Station",
"./GBFS/free_bike_status.json": "gbfs:Bike",
"./GBFS/system_alerts.json": "gbfs:Alert",
"./GBFS/system_regions.json": "gbfs:Region",
"./GBFS/vehicle_types.json": "gbfs:VehicleType",
"./GBFS/system_pricing_plan.json": "gbfs:PricingPlan",
"./GBFS/gbfs_versions.json": "gbfs:Version",
"./GBFS/system_calendar.json": "gbfs:Calendar",
"./GBFS/system_hours.json": "gbfs:RentalHour"
},
"shaclTargets": {
"gbfs:Station": "<https://w3id.org/gbfs/terms/station>",
"gbfs:Bike": "<https://w3id.org/gbfs/terms/bike>",
......@@ -51,6 +39,18 @@
"gbfs:RentalHour": "<https://w3id.org/gbfs/terms/rentalHour>",
"gbfs:Feed": "<https://w3id.org/gbfs/terms/feed>"
},
"sources": {
"./GBFS/station_information.json": "gbfs:Station",
"./GBFS/free_bike_status.json": "gbfs:Bike",
"./GBFS/system_alerts.json": "gbfs:Alert",
"./GBFS/system_regions.json": "gbfs:Region",
"./GBFS/vehicle_types.json": "gbfs:VehicleType",
"./GBFS/system_pricing_plan.json": "gbfs:PricingPlan",
"./GBFS/gbfs_versions.json": "gbfs:Version",
"./GBFS/system_calendar.json": "gbfs:Calendar",
"./GBFS/system_hours.json": "gbfs:RentalHour"
},
"shaclRoot": "<https://w3id.org/gbfs/terms/>",
......
......@@ -7,13 +7,13 @@ var namedNode = DataFactory.namedNode, literal = DataFactory.literal, defaultGra
var config = require('./configs/config-gbfs.json');
var writer = new N3.Writer({ prefixes: config.prefixes });
var prefix = "sdm";
var rdf_json_objects = new Map();
RDFTools.initialise("ElectricalMeasurement");
//let schema = require('./GBFS/system_pricing_plan.json');
//let schema = require('./GBFS/station_information.json');
var schema = require('./GBFS/station_information.json');
//let schema = require('./GBFS/system_hours.json');
//let schema = require('./SmartDataModels/battery.json');
//let schema = require('./SmartDataModels/dataModel.json');
var schema = require('./GBFS/minecraft.json');
function traverse(parentKey, schema, propertyList) {
if (!schema) {
return;
......@@ -23,29 +23,34 @@ function traverse(parentKey, schema, propertyList) {
// Base cases
if (schema.type === 'string') { // Base Case
console.log("string: ");
writer.addQuad(RDFTools.node_node_node(parentKey, 'rdfs:range', 'xsd:string'));
return parentKey;
}
if (schema.type === 'number') { // Base Case
console.log("number: ");
writer.addQuad(RDFTools.node_node_node(parentKey, 'rdfs:range', 'xsd:integer'));
return parentKey;
}
if (schema.type === 'integer') { // Base Case
console.log("integer: ");
writer.addQuad(RDFTools.node_node_node(parentKey, 'rdfs:range', 'xsd:integer'));
return parentKey;
}
if (schema.type === 'boolean') {
console.log("boolean: ");
// Base Case
writer.addQuad(RDFTools.node_node_node(parentKey, 'rdfs:range', 'xsd:boolean'));
return parentKey;
}
if (schema["enum"] != undefined) {
console.log("enum: ");
writer.addQuad(getOneOfQuad(schema.items["enum"], parentKey));
// key oneOf <-,-,-,-,->
return;
}
if (schema.type === 'array') {
console.log("array: ");
console.log("array schema", schema);
writer.addQuad(RDFTools.node_node_node(parentKey, 'rdf:type', 'rdfs:Class'));
if (schema.items != undefined) {
//
if (schema.items.type === 'object') {
......
......@@ -11,24 +11,16 @@ const { namedNode, literal, defaultGraph, quad } = DataFactory;
let config = require('./configs/config-gbfs.json');
let writer = new N3.Writer({prefixes:config.prefixes});
let prefix ="sdm";
let rdf_json_objects = new Map<string, string>();
RDFTools.initialise("ElectricalMeasurement");
//let schema = require('./GBFS/system_pricing_plan.json');
//let schema = require('./GBFS/station_information.json');
let schema = require('./GBFS/station_information.json');
//let schema = require('./GBFS/system_hours.json');
//let schema = require('./SmartDataModels/battery.json');
//let schema = require('./SmartDataModels/dataModel.json');
let schema = require('./GBFS/minecraft.json');
function traverse (parentKey, schema, propertyList ){
......@@ -43,23 +35,28 @@ function traverse (parentKey, schema, propertyList ){
if (schema.type === 'string') {// Base Case
console.log("string: ")
writer.addQuad(RDFTools.node_node_node(parentKey, 'rdfs:range', 'xsd:string'));
return parentKey;
}
if (schema.type === 'number') { // Base Case
console.log("number: ")
writer.addQuad(RDFTools.node_node_node(parentKey, 'rdfs:range', 'xsd:integer'));
return parentKey;
}
if (schema.type === 'integer') {// Base Case
console.log("integer: ")
writer.addQuad(RDFTools.node_node_node(parentKey, 'rdfs:range', 'xsd:integer'));
return parentKey;
}
if (schema.type === 'boolean') {
console.log("boolean: ")
// Base Case
writer.addQuad(RDFTools.node_node_node(parentKey, 'rdfs:range', 'xsd:boolean'));
return parentKey;
}
if (schema.enum != undefined){
console.log("enum: ");
writer.addQuad(getOneOfQuad(schema.items.enum, parentKey));
// key oneOf <-,-,-,-,->
return;
}
......@@ -68,6 +65,8 @@ function traverse (parentKey, schema, propertyList ){
console.log("array: ");
console.log("array schema", schema);
writer.addQuad(RDFTools.node_node_node(parentKey, 'rdf:type', 'rdfs:Class' ));
if (schema.items != undefined){
//
if (schema.items.type === 'object'){
......@@ -77,9 +76,6 @@ function traverse (parentKey, schema, propertyList ){
traverse(item, schema.items[item], [])
//console.log("item", item);
}
}
if(schema.items.enum != undefined){// If there is an enum
writer.addQuad(getOneOfQuad(schema.items.enum, parentKey));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment