-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a basic RDF version of SlideWIki
- Loading branch information
Showing
12 changed files
with
392 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
node_modules | ||
build | ||
*.log | ||
logs/*.log | ||
tmp.js | ||
*.lock | ||
.DS_Store | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{"_id":122141,"user":17676,"hidden":true,"accessLevel":null,"editors":{"users":[],"groups":[]},"timestamp":"2018-10-22T20:32:19.133Z","description":"","translated_from":null,"lastUpdate":"2018-10-22T20:32:19.149Z","datasource":null,"license":"CC BY-SA","contributors":[{"user":17676,"count":1}],"active":1,"revisions":[{"id":1,"usage":[{"id":122124,"revision":1}],"title":"New deck","timestamp":"2018-10-22T20:32:19.133Z","lastUpdate":"2018-10-22T20:32:19.149Z","user":17676,"language":"en","parent":null,"tags":[],"comment":null,"abstract":null,"footer":null,"contentItems":[{"order":1,"ref":{"id":797935,"revision":1},"kind":"slide"}],"variants":[],"theme":"default","allowMarkdown":false}]} | ||
{"_id":122142,"user":17868,"hidden":true,"accessLevel":null,"editors":{"users":[],"groups":[]},"timestamp":"2018-10-22T20:48:14.023Z","description":"Theory Exercise 3 E and J","translated_from":{"status":"original"},"lastUpdate":"2018-10-22T21:57:56.357Z","datasource":null,"license":"CC BY-SA","contributors":[{"user":17868,"count":17}],"active":1,"revisions":[{"id":1,"usage":[],"title":"MaxwellSilversteinTheoryExercise3","timestamp":"2018-10-22T20:48:14.023Z","lastUpdate":"2018-10-22T21:57:56.357Z","user":17868,"language":"en","parent":null,"tags":[],"comment":null,"abstract":null,"footer":null,"contentItems":[{"order":1,"ref":{"id":797956,"revision":4},"kind":"slide"},{"order":2,"ref":{"id":797963,"revision":3},"kind":"slide"},{"order":3,"ref":{"id":797964,"revision":4},"kind":"slide"},{"order":4,"kind":"slide","ref":{"id":797968,"revision":3},"variants":[]},{"order":5,"ref":{"id":797973,"revision":3},"kind":"slide"},{"order":6,"ref":{"id":797974,"revision":2},"kind":"slide"},{"order":7,"ref":{"id":797977,"revision":2},"kind":"slide"}],"variants":[],"theme":"default","allowMarkdown":false}]} | ||
{"_id":122143,"user":17835,"hidden":false,"accessLevel":null,"editors":{"users":[],"groups":[]},"timestamp":"2018-10-22T21:01:36.251Z","description":"Van Duyne presentation of groups of characteristics I and J","translated_from":{"status":"original"},"lastUpdate":"2018-10-22T21:59:52.384Z","datasource":null,"license":"CC BY-SA","contributors":[{"user":17835,"count":18}],"active":1,"revisions":[{"id":1,"usage":[],"title":"Van Duyne I and L","timestamp":"2018-10-22T21:01:36.251Z","lastUpdate":"2018-10-22T21:59:52.384Z","user":17835,"language":"en","parent":null,"tags":[],"comment":null,"abstract":null,"footer":null,"contentItems":[{"order":1,"ref":{"id":797950,"revision":5},"kind":"slide"},{"order":2,"kind":"slide","ref":{"id":797980,"revision":1},"variants":[]},{"order":3,"kind":"slide","ref":{"id":797951,"revision":3},"variants":[]},{"order":4,"kind":"slide","ref":{"id":797959,"revision":2},"variants":[]},{"order":5,"kind":"slide","ref":{"id":797961,"revision":3},"variants":[]},{"order":6,"kind":"slide","ref":{"id":797966,"revision":2},"variants":[]},{"order":7,"kind":"slide","ref":{"id":797967,"revision":2},"variants":[]},{"order":8,"kind":"slide","ref":{"id":797971,"revision":3},"variants":[]},{"order":9,"kind":"slide","ref":{"id":797976,"revision":2},"variants":[]},{"order":10,"kind":"slide","ref":{"id":797978,"revision":2},"variants":[]}],"variants":[],"theme":"default","allowMarkdown":false,"description":"Van Duyne presentation of groups of characteristics I and J"}]} | ||
{"_id":122144,"user":17711,"hidden":true,"accessLevel":null,"editors":{"users":[],"groups":[]},"timestamp":"2018-10-22T21:14:07.261Z","description":"Pattern D - Writing and Managing Content\n\nLuis Antillon, Jacqueline Levitan, Sam Osheroff, Marie Rogers","translated_from":{"status":"original"},"lastUpdate":"2018-10-22T21:38:01.524Z","datasource":null,"license":"CC BY-SA","contributors":[{"user":17711,"count":9}],"active":1,"revisions":[{"id":1,"usage":[],"title":"UI Van Duyne Pattern D","timestamp":"2018-10-22T21:14:07.261Z","lastUpdate":"2018-10-22T21:38:01.524Z","user":17711,"language":"en","parent":null,"tags":[],"comment":null,"abstract":null,"footer":null,"contentItems":[{"order":1,"ref":{"id":797952,"revision":2},"kind":"slide"},{"order":2,"ref":{"id":797958,"revision":6},"kind":"slide"}],"variants":[],"theme":"default","allowMarkdown":false,"description":"Pattern D - Writing and Managing Content\n\nLuis Antillon, Jacqueline Levitan, Sam Osheroff, Marie Rogers"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{"_id":13402,"user":360,"description":"","datasource":null,"lastUpdate":"2017-07-19T09:19:33.657Z","timestamp":"2013-05-30T15:30:56.000Z","license":"CC BY-SA","contributors":[{"user":360,"count":1,"_id":{"$oid":"596f42e9e094a20011d3da76"}}],"revisions":[{"_id":1,"id":1,"mysql_id":28815,"user":360,"content":"\u003cdiv lang=\"fr-x-mtfrom-\"\u003e\n\u003ch3\u003e Les principaux enjeux de Data Mining \u003c/h3\u003e\n\u003cdiv\u003e\u003c/div\u003e\n\u003cdiv\u003e\u003c/div\u003e\n\u003cdiv\u003e\u003cul\u003e\n\u003cli\u003e Méthodologie de l'exploitation minière \u003c/li\\","timestamp":"2013-05-30T15:30:56.000Z","language":"fr","comment":"","usage":[{"id":1692,"revision":1,"_id":{"$oid":"596f424ae094a20011d35c97"}},{"id":1692,"revision":2,"_id":{"$oid":"596f424ae094a20011d35c99"}},{"id":1692,"revision":3,"_id":{"$oid":"596f424ae094a20011d35c9b"}},{"id":1692,"revision":4,"_id":{"$oid":"596f424ae094a20011d35c9d"}},{"id":1692,"revision":5,"_id":{"$oid":"596f424ae094a20011d35c9f"}},{"id":1692,"revision":6,"_id":{"$oid":"596f424ae094a20011d35ca1"}},{"id":1692,"revision":7,"_id":{"$oid":"596f424ae094a20011d35ca3"}},{"id":1692,"revision":8,"_id":{"$oid":"596f424ae094a20011d35ca5"}},{"id":1692,"revision":9,"_id":{"$oid":"596f424ae094a20011d35ca7"}},{"id":1692,"revision":10,"_id":{"$oid":"596f424ae094a20011d35ca9"}}],"dataSources":[],"media":[],"tags":[],"parent":{"id":null,"revision":null}}],"origin":{"id":10428,"mysql_revision":22269,"revision":2,"user":141,"title":null},"translations":[],"__v":12} | ||
{"_id":13403,"user":360,"description":"","datasource":null,"lastUpdate":"2017-07-19T09:19:33.665Z","timestamp":"2013-05-30T15:30:56.000Z","license":"CC BY-SA","contributors":[{"user":360,"count":1,"_id":{"$oid":"596f42e9e094a20011d3da77"}}],"revisions":[{"_id":1,"id":1,"mysql_id":28816,"user":360,"content":"\u003cdiv lang=\"fr-x-mtfrom-\"\u003e\n\u003ch3\u003e Les principaux enjeux de Data Mining (SUITE) u003e Extraction de données Invisible \u003c/li\u003e\n\u003cc c/ul\u003e\n\u003c/ul\u003e\u003c/div\u003e\n\u003c/div\u003e","title":" Les principaux enjeux de Data Mining (SUITE ","timestamp":"2013-05-30T15:30:56.000Z","language":"fr","comment":"","usage":[{"id":1692,"revision":1,"_id":{"$oid":"596f424ae094a20011d35c98"}},{"id":1692,"revision":2,"_id":{"$oid":"596f424ae094a20011d35c9a"}},{"id":1692,"revision":3,"_id":{"$oid":"596f424ae094a20011d35c9c"}},{"id":1692,"revision":4,"_id":{"$oid":"596f424ae094a20011d35c9e"}},{"id":1692,"revision":5,"_id":{"$oid":"596f424ae094a20011d35ca0"}},{"id":1692,"revision":6,"_id":{"$oid":"596f424ae094a20011d35ca2"}},{"id":1692,"revision":7,"_id":{"$oid":"596f424ae094a20011d35ca4"}},{"id":1692,"revision":8,"_id":{"$oid":"596f424ae094a20011d35ca6"}},{"id":1692,"revision":9,"_id":{"$oid":"596f424ae094a20011d35ca8"}},{"id":1692,"revision":10,"_id":{"$oid":"596f424ae094a20011d35caa"}}],"dataSources":[],"media":[],"tags":[],"parent":{"id":null,"revision":null}}],"origin":{"id":10429,"mysql_revision":22270,"revision":2,"user":141,"title":null},"translations":[],"__v":12} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{"_id":12,"defaultName":"Datenschutz","user":14578,"tagName":"datenschutz","timestamp":"2017-07-25T09:55:03.690Z"} | ||
{"_id":13,"defaultName":"Datensicherheit","user":14578,"tagName":"datensicherheit","timestamp":"2017-07-25T09:55:27.322Z"} | ||
{"_id":14,"defaultName":"Daten","user":14578,"tagName":"daten","timestamp":"2017-07-25T09:55:27.325Z"} | ||
{"_id":15,"defaultName":"Schulen","user":14578,"tagName":"schulen","timestamp":"2017-07-25T09:55:27.328Z"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{"_id":795,"id":795,"name":"Test Group","description":"Test group edited with JMeter3","isActive":true,"timestamp":"2017-09-28T08:15:58.218Z","members":[],"creator":{"userid":120002,"username":"testuser03"}} | ||
{"_id":796,"id":796,"name":"Test Group","description":"Test group edited with JMeter3","isActive":true,"timestamp":"2017-09-28T08:16:02.248Z","members":[],"creator":{"userid":120013,"username":"testuser14"}} | ||
{"_id":797,"id":797,"name":"Test Group","description":"Test group edited with JMeter3","isActive":true,"timestamp":"2017-09-28T08:16:03.349Z","members":[],"creator":{"userid":120006,"username":"testuser07"}} | ||
{"_id":798,"id":798,"name":"Test Group","description":"Test group edited with JMeter3","isActive":true,"timestamp":"2017-09-28T08:16:04.208Z","members":[],"creator":{"userid":120008,"username":"testuser09"}} | ||
{"_id":799,"name":"Test Group","description":"Test group created with JMeter","isActive":true,"timestamp":"2017-09-28T08:16:04.682Z","members":[],"creator":{"userid":120004,"username":"testuser05"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{"_id":1.2010095e+07,"surname":"Doe","forename":"John","username":"testuser95","email":"[email protected]","password":"7c8d0e66bacf172c9164a3571050c7126e62e2f93dd56f319dcbd549fd04a79eee9a91d24ae2c3910ae077cfb99639b8ed4f97bd20807fa8597fb3ff7e15778c","frontendLanguage":"en","country":"","picture":"","description":"A short biography about the user","organization":"","registered":"2017-09-22T09:22:03.928Z","providers":[],"activate_secret":"564e4c69c34d81be83a10829da4bb63a4a44ba7748bbec3c21bc03fb49c331c7f8613c8c71e63a016157be39915991335fc064b4fd274fce497a2fad1c09bb3a","authorised":true} | ||
{"_id":1.2010096e+07,"surname":"Doe","forename":"John","username":"testuser96","email":"[email protected]","password":"7c8d0e66bacf172c9164a3571050c7126e62e2f93dd56f319dcbd549fd04a79eee9a91d24ae2c3910ae077cfb99639b8ed4f97bd20807fa8597fb3ff7e15778c","frontendLanguage":"en","country":"","picture":"","description":"A short biography about the user","organization":"","registered":"2017-09-22T09:22:03.928Z","providers":[],"activate_secret":"564e4c69c34d81be83a10829da4bb63a4a44ba7748bbec3c21bc03fb49c331c7f8613c8c71e63a016157be39915991335fc064b4fd274fce497a2fad1c09bb3a","authorised":true} | ||
{"_id":1.2010097e+07,"surname":"Doe","forename":"John","username":"testuser97","email":"[email protected]","password":"7c8d0e66bacf172c9164a3571050c7126e62e2f93dd56f319dcbd549fd04a79eee9a91d24ae2c3910ae077cfb99639b8ed4f97bd20807fa8597fb3ff7e15778c","frontendLanguage":"en","country":"","picture":"","description":"A short biography about the user","organization":"","registered":"2017-09-22T09:22:03.928Z","providers":[],"activate_secret":"564e4c69c34d81be83a10829da4bb63a4a44ba7748bbec3c21bc03fb49c331c7f8613c8c71e63a016157be39915991335fc064b4fd274fce497a2fad1c09bb3a","authorised":true} | ||
{"_id":1.2010098e+07,"surname":"Doe","forename":"John","username":"testuser98","email":"[email protected]","password":"7c8d0e66bacf172c9164a3571050c7126e62e2f93dd56f319dcbd549fd04a79eee9a91d24ae2c3910ae077cfb99639b8ed4f97bd20807fa8597fb3ff7e15778c","frontendLanguage":"en","country":"","picture":"","description":"A short biography about the user","organization":"","registered":"2017-09-22T09:22:03.928Z","providers":[],"activate_secret":"564e4c69c34d81be83a10829da4bb63a4a44ba7748bbec3c21bc03fb49c331c7f8613c8c71e63a016157be39915991335fc064b4fd274fce497a2fad1c09bb3a","authorised":true} | ||
{"_id":1.2010099e+07,"surname":"Doe","forename":"John","username":"testuser99","email":"[email protected]","password":"7c8d0e66bacf172c9164a3571050c7126e62e2f93dd56f319dcbd549fd04a79eee9a91d24ae2c3910ae077cfb99639b8ed4f97bd20807fa8597fb3ff7e15778c","frontendLanguage":"en","country":"","picture":"","description":"A short biography about the user","organization":"","registered":"2017-09-22T09:22:03.928Z","providers":[],"activate_secret":"564e4c69c34d81be83a10829da4bb63a4a44ba7748bbec3c21bc03fb49c331c7f8613c8c71e63a016157be39915991335fc064b4fd274fce497a2fad1c09bb3a","authorised":true} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
var ndjson = require('ndjson'); | ||
var fs = require('fs'); | ||
|
||
const prefixes = ` | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@prefix swV: <http://rdf.slidewiki.org/vocab/> . | ||
@prefix swR: <https://slidewiki.org/deck/> . | ||
@prefix swTagR: <https://slidewiki.org/tag/> . | ||
@prefix swUserR: <https://slidewiki.org/user/> . | ||
@prefix swSlideR: <https://slidewiki.org/slideview/> . | ||
@prefix prv: <http://purl.org/net/provenance/ns#> . | ||
`; | ||
//write prefixes | ||
console.log(prefixes); | ||
|
||
fs.createReadStream('data/decks.txt') | ||
.pipe(ndjson.parse()) | ||
.on('data', function(obj) { | ||
convertToRDF(obj); | ||
}); | ||
|
||
//list of selected properties | ||
const selected = [ | ||
'_id', | ||
'hidden', | ||
'user', | ||
'description', | ||
'timestamp', | ||
'lastUpdate', | ||
'license', | ||
'contributors', //esp | ||
'active', | ||
'revisions' //esp | ||
]; | ||
const idField = '_id'; | ||
|
||
function convertToRDF(obj) { | ||
//print turtle | ||
let id = obj[idField]; | ||
console.log('#######'+id+'#########'); | ||
console.log(` | ||
swR:${id} a swV:Deck . | ||
`); | ||
for(let prop in obj){ | ||
if(selected.indexOf(prop) !== -1){ | ||
//custom properties | ||
if(prop === 'user'){ | ||
console.log(` | ||
swR:${id} prv:createdBy swUserR:${obj[prop]} . | ||
`); | ||
continue; | ||
} | ||
if(prop === 'contributors'){ | ||
obj[prop].forEach((item)=>{ | ||
console.log(` | ||
swR:${id} swV:hasContibutor swUserR:${item.user} . | ||
`); | ||
}); | ||
continue; | ||
} | ||
if(prop === 'revisions'){ | ||
obj[prop].forEach((item)=>{ | ||
console.log(` | ||
swR:${id} swV:hasRevision swR:${id}-${item.id} . | ||
swR:${id}-${item.id} a swV:DeckRevision ; | ||
swV:title """${item.title}""" ; | ||
swV:timestamp """${item.timestamp}""" ; | ||
swV:lastUpdate """${item.lastUpdate}""" ; | ||
swV:language """${item.language}""" ; | ||
swV:abstract """${item.abstract ? item.abstract : '-'}""" ; | ||
swV:theme """${item.theme}""" ; | ||
swV:allowMarkdown """${item.allowMarkdown}""" ; | ||
prv:createdBy swUserR:${item.user} . | ||
`); | ||
if(item.tags.length){ | ||
item.tags.forEach((tag)=>{ | ||
console.log(` | ||
swR:${id}-${item.id} swV:hasTag swTagR:${tag.id} . | ||
`); | ||
}); | ||
} | ||
item.contentItems.forEach((content)=>{ | ||
if(content.kind === 'slide'){ | ||
console.log(` | ||
swR:${id}-${item.id} swV:hasContentItem swR:${id}-${item.id}/${content.kind}/${content.ref.id}-${content.ref.revision} . | ||
swR:${id}-${item.id}/${content.kind}/${content.ref.id}-${content.ref.revision} a swV:SlideRevision ; | ||
swV:isRevisedFrom swSlideR:${content.ref.id} ; | ||
swV:isEqualTo swSlideR:${content.ref.id}-${content.ref.revision} ; | ||
swV:order """${content.order}""" . | ||
`); | ||
}else{ | ||
console.log(` | ||
swR:${id}-${item.id} swV:hasContentItem swR:${id}-${item.id}/${content.kind}/${content.ref.id}-${content.ref.revision} . | ||
swR:${id}-${item.id}/${content.kind}/${content.ref.id}-${content.ref.revision} a swV:DeckRevision ; | ||
swV:isRevisedFrom swR:${content.ref.id} ; | ||
swV:isEqualTo swR:${content.ref.id}-${content.ref.revision} ; | ||
swV:order """${content.order}""" . | ||
`); | ||
} | ||
|
||
}); | ||
|
||
}); | ||
continue; | ||
} | ||
console.log(` | ||
swR:${id} swV:${prop} """${obj[prop] ? obj[prop] : '-'}""" . | ||
`); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "json-to-rdf", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "usersToRDF.js", | ||
"dependencies": { | ||
"ndjson": "^1.5.0" | ||
}, | ||
"devDependencies": {}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
var ndjson = require('ndjson'); | ||
var fs = require('fs'); | ||
|
||
const prefixes = ` | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@prefix swV: <http://rdf.slidewiki.org/vocab/> . | ||
@prefix swR: <https://slidewiki.org/slideview/> . | ||
@prefix swTagR: <https://slidewiki.org/tag/> . | ||
@prefix swUserR: <https://slidewiki.org/user/> . | ||
@prefix swDeckR: <https://slidewiki.org/deck/> . | ||
@prefix prv: <http://purl.org/net/provenance/ns#> . | ||
`; | ||
//write prefixes | ||
console.log(prefixes); | ||
|
||
fs.createReadStream('data/slides.txt') | ||
.pipe(ndjson.parse()) | ||
.on('data', function(obj) { | ||
convertToRDF(obj); | ||
}); | ||
|
||
//list of selected properties | ||
const selected = [ | ||
'_id', | ||
'user', | ||
'timestamp', | ||
'lastUpdate', | ||
'license', | ||
'contributors', //esp | ||
'revisions' //esp | ||
]; | ||
const idField = '_id'; | ||
|
||
function convertToRDF(obj) { | ||
//print turtle | ||
let id = obj[idField]; | ||
console.log('#######'+id+'#########'); | ||
console.log(` | ||
swR:${id} a swV:Slide . | ||
`); | ||
for(let prop in obj){ | ||
if(selected.indexOf(prop) !== -1){ | ||
//custom properties | ||
if(prop === 'user'){ | ||
console.log(` | ||
swR:${id} prv:createdBy swUserR:${obj[prop]} . | ||
`); | ||
continue; | ||
} | ||
if(prop === 'contributors'){ | ||
obj[prop].forEach((item)=>{ | ||
console.log(` | ||
swR:${id} swV:hasContibutor swUserR:${item.user} . | ||
`); | ||
}); | ||
continue; | ||
} | ||
if(prop === 'revisions'){ | ||
obj[prop].forEach((item)=>{ | ||
console.log(` | ||
swR:${id} swV:hasRevision swR:${id}-${item.id} . | ||
swR:${id}-${item.id} a swV:SlideRevision ; | ||
swV:title """${item.title}""" ; | ||
swV:timestamp """${item.timestamp}""" ; | ||
swV:content """${item.content}""" ; | ||
swV:speakernotes """${item.speakernotes ? item.speakernotes : '-'}""" ; | ||
prv:createdBy swUserR:${item.user} . | ||
`); | ||
|
||
}); | ||
continue; | ||
} | ||
console.log(` | ||
swR:${id} swV:${prop} """${obj[prop] ? obj[prop] : '-'}""" . | ||
`); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
var ndjson = require('ndjson'); | ||
var fs = require('fs'); | ||
|
||
const prefixes = ` | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@prefix swV: <http://rdf.slidewiki.org/vocab/> . | ||
@prefix swR: <https://slidewiki.org/tag/> . | ||
@prefix swUserR: <https://slidewiki.org/user/> . | ||
@prefix prv: <http://purl.org/net/provenance/ns#> . | ||
`; | ||
//write prefixes | ||
console.log(prefixes); | ||
|
||
fs.createReadStream('data/tags.txt') | ||
.pipe(ndjson.parse()) | ||
.on('data', function(obj) { | ||
convertToRDF(obj); | ||
}); | ||
|
||
//list of selected properties | ||
const selected = [ | ||
'_id', | ||
'defaultName', | ||
'user', | ||
'tagName', | ||
'timestamp' | ||
]; | ||
const idField = '_id'; | ||
|
||
function convertToRDF(obj) { | ||
//print turtle | ||
let id = obj[idField]; | ||
console.log('#######'+id+'#########'); | ||
console.log(` | ||
swR:${id} a swV:Tag . | ||
`); | ||
for(let prop in obj){ | ||
if(selected.indexOf(prop) !== -1){ | ||
//custom properties | ||
if(prop === 'user'){ | ||
console.log(` | ||
swR:${id} prv:createdBy swUserR:${obj[prop]} . | ||
`); | ||
continue; | ||
} | ||
console.log(` | ||
swR:${id} swV:${prop} """${obj[prop] ? obj[prop] : '-'}""" . | ||
`); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
var ndjson = require('ndjson'); | ||
var fs = require('fs'); | ||
|
||
const prefixes = ` | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@prefix swV: <http://rdf.slidewiki.org/vocab/> . | ||
@prefix swR: <https://slidewiki.org/usergroup/> . | ||
@prefix swUserR: <https://slidewiki.org/user/> . | ||
`; | ||
//write prefixes | ||
console.log(prefixes); | ||
|
||
fs.createReadStream('data/usergroups.txt') | ||
.pipe(ndjson.parse()) | ||
.on('data', function(obj) { | ||
convertToRDF(obj); | ||
}); | ||
|
||
//list of selected properties | ||
const selected = [ | ||
'_id', | ||
'name', | ||
'description', | ||
'isActive', | ||
'timestamp', | ||
'members', | ||
'creator' | ||
]; | ||
const idField = '_id'; | ||
|
||
function convertToRDF(obj) { | ||
//print turtle | ||
let id = obj[idField]; | ||
console.log(` | ||
swR:${id} a swV:UserGroup . | ||
`); | ||
for(let prop in obj){ | ||
if(selected.indexOf(prop) !== -1){ | ||
if(prop === 'creator'){ | ||
console.log(` | ||
swR:${id} prv:createdBy swUserR:${obj[prop].userid} . | ||
`); | ||
continue; | ||
} | ||
if(prop === 'members'){ | ||
obj[prop].forEach((item)=>{ | ||
console.log(` | ||
swR:${id} swV:hasMember swUserR:${item.userid} . | ||
`); | ||
}); | ||
continue; | ||
} | ||
|
||
console.log(` | ||
swR:${id} swV:${prop} """${obj[prop] ? obj[prop] : '-'}""" . | ||
`); | ||
} | ||
} | ||
console.log('################'); | ||
} |
Oops, something went wrong.