More info and prep for pagerank
This commit is contained in:
parent
2b48dd6c62
commit
4045f05121
11 changed files with 159 additions and 19 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "ranking/PageRank"]
|
||||
path = ranking/PageRank
|
||||
url = https://github.com/ashkonf/PageRank
|
|
@ -18,12 +18,16 @@ RewriteRule "^exhibition/mood_swings$" "index.html"
|
|||
RewriteRule "^exhibition/route-du-nord$" "index.html"
|
||||
RewriteRule "^exhibition/stateofemotion$" "index.html"
|
||||
RewriteRule "^exhibition/the-new-current$" "index.html"
|
||||
RewriteRule "^eye-without-a-face$" "index.html"
|
||||
RewriteRule "^eye-without-a-face/video$" "index.html"
|
||||
RewriteRule "^festival/statefestival$" "index.html"
|
||||
RewriteRule "^guest-worker$" "index.html"
|
||||
RewriteRule "^guest-worker/image/1$" "index.html"
|
||||
RewriteRule "^guest-worker/image/2$" "index.html"
|
||||
RewriteRule "^guest-worker/image/3$" "index.html"
|
||||
RewriteRule "^guest-worker/video/1$" "index.html"
|
||||
RewriteRule "^guest-worker/report$" "index.html"
|
||||
RewriteRule "^guest-worker/video/outcome$" "index.html"
|
||||
RewriteRule "^guest-worker/video/process$" "index.html"
|
||||
RewriteRule "^heartbeat$" "index.html"
|
||||
RewriteRule "^heartbeat/image/1$" "index.html"
|
||||
RewriteRule "^in4art-salon$" "index.html"
|
||||
|
@ -64,6 +68,7 @@ RewriteRule "^venue/tivoli$" "index.html"
|
|||
RewriteRule "^venue/zoho$" "index.html"
|
||||
RewriteRule "^workshop/plotting-data-das-theatre$" "index.html"
|
||||
RewriteRule "^workshop/plotting-data-onomatopee$" "index.html"
|
||||
RewriteRule "^www$" "index.html"
|
||||
RewriteRule "^@type/Event$" "index.html"
|
||||
RewriteRule "^@type/Report$" "index.html"
|
||||
RewriteRule "^@type/VideoObject$" "index.html"
|
||||
|
@ -79,3 +84,4 @@ RewriteRule "^@type/EventVenue$" "index.html"
|
|||
RewriteRule "^@type/Museum$" "index.html"
|
||||
RewriteRule "^@type/PerformingGroup$" "index.html"
|
||||
RewriteRule "^@type/CollegeOrUniversity$" "index.html"
|
||||
RewriteRule "^@type/WebSite$" "index.html"
|
||||
|
|
BIN
assets/image/guest_worker02.jpg
(Stored with Git LFS)
BIN
assets/image/guest_worker02.jpg
(Stored with Git LFS)
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
assets/thumb/guest_worker02.jpg
(Stored with Git LFS)
BIN
assets/thumb/guest_worker02.jpg
(Stored with Git LFS)
Binary file not shown.
File diff suppressed because one or more lines are too long
2
ranking/.gitignore
vendored
Normal file
2
ranking/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
venv/
|
||||
|
1
ranking/PageRank
Submodule
1
ranking/PageRank
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit a138d0edb53135e0c070b3f5cc4a5b0b37dc778e
|
94
ranking/jsonld_ranking.py
Normal file
94
ranking/jsonld_ranking.py
Normal file
|
@ -0,0 +1,94 @@
|
|||
from pyld import jsonld
|
||||
import json
|
||||
|
||||
import PageRank.pagerank as pagerank
|
||||
|
||||
# use flattened jsonld
|
||||
with open('../assets/js/rubenvandeven.jsonld', 'r') as fp:
|
||||
contents = json.load(fp)['@graph']
|
||||
|
||||
linksPerItem = {}
|
||||
|
||||
def addCount(fromId, toId, weight):
|
||||
if fromId not in linksPerItem:
|
||||
linksPerItem[fromId] = {}
|
||||
if not toId in linksPerItem[fromId]:
|
||||
linksPerItem[fromId][toId] = 0
|
||||
linksPerItem[fromId][toId] += weight
|
||||
|
||||
def addLink(fromId, toId, weight = 1):
|
||||
addCount(fromId, toId, weight)
|
||||
addCount(toId, fromId, weight)
|
||||
|
||||
for node in contents:
|
||||
currentId = node['@id']
|
||||
for key, value in node.items():
|
||||
if type(value) == dict:
|
||||
value = [value]
|
||||
|
||||
if type(value) == list:
|
||||
for link in value:
|
||||
if not type(link) == dict:
|
||||
# can be any other list, eg. list of urls
|
||||
continue
|
||||
|
||||
weight = 1
|
||||
if key == 'https://schema.org/author':
|
||||
weight = 2
|
||||
elif key == 'https://schema.org/contributor':
|
||||
weight = .5
|
||||
|
||||
# print(link)
|
||||
linkedId = link['@id']
|
||||
addLink(currentId, linkedId)
|
||||
|
||||
|
||||
targetMin = .7
|
||||
targetMax = 1.5
|
||||
|
||||
values = pagerank.powerIteration(linksPerItem)
|
||||
|
||||
normalised = targetMin + (values - min(values)) * (targetMax-targetMin)/max(values)
|
||||
print(json.dumps(dict(normalised)))
|
||||
#
|
||||
# factor = 1 / min(values)
|
||||
# print(factor)
|
||||
# normalised = values * factor
|
||||
# normalised -
|
||||
|
||||
#
|
||||
# for(let nodeId in data) {
|
||||
# let node = data[nodeId];
|
||||
# let currentId = node["@id"];
|
||||
# for(let key in node){
|
||||
# let nodeAttr = Array.isArray(node[key]) ? node[key] : [node[key]];
|
||||
# // // relations should always be lists (eases assumptions)
|
||||
# // if(typeof node[key] !== "Array" && typeof node[key]['id'] !== "undefined") {
|
||||
# // node[key] = [node[key]];
|
||||
# // }
|
||||
# // every attribute is an Array after flatten(), loop them
|
||||
# for(let i in nodeAttr) {
|
||||
# if(key !== "@id" && typeof nodeAttr[i] === "string" && nodes[nodeAttr[i]]) {
|
||||
# links[links.length] = {
|
||||
# "source": currentId,
|
||||
# "target": nodeAttr[i],
|
||||
# "name": key
|
||||
# };
|
||||
# }
|
||||
# else if(typeof nodeAttr[i]["@id"] !== "undefined") {
|
||||
# // if there is just one item, flatten/expand has turned urls in objects with just an id
|
||||
# // reverse this, as we don't want these separate for this project
|
||||
# if (Object.keys(nodeAttr[i]).length == 1 && typeof nodes[nodeAttr[i]["@id"]] === "undefined") {
|
||||
# // skip
|
||||
# // nodeAttr = nodeAttr[i]["id"];
|
||||
# } else {
|
||||
# links[links.length] = {
|
||||
# "source": currentId,
|
||||
# "target": nodeAttr[i]["@id"],
|
||||
# "name": key
|
||||
# };
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# }
|
2
ranking/requirements.txt
Normal file
2
ranking/requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
PyLD==1.0.5
|
||||
pandas
|
|
@ -5,9 +5,9 @@
|
|||
"r": "https://rubenvandeven.com"
|
||||
},
|
||||
"@type": "WebSite",
|
||||
"@id": "r:#site",
|
||||
"@id": "r:/www",
|
||||
"url": "https://rubenvandeven.com",
|
||||
"s:seeAlso": [ "https://rubenvandeven.com/rubenvandeven.jsonld", "https://rubenvandeven.com/foaf.rdf#me"],
|
||||
"s:seeAlso": [ "https://rubenvandeven.com/rubenvandeven.jsonld", "https://git.rubenvandeven.com/r/portfolio"],
|
||||
"author":
|
||||
{
|
||||
"@id": "r:/",
|
||||
|
@ -199,14 +199,24 @@
|
|||
"thumbnailUrl": "/assets\/thumb\/guest_worker03.jpg"
|
||||
}
|
||||
],
|
||||
"video": {
|
||||
"@id": "r:/guest-worker/video/1",
|
||||
"@type": "VideoObject",
|
||||
"thumbnailUrl": "/assets\/thumb\/guest_worker04.jpg",
|
||||
"contentUrl": "http://works.rubenvandeven.com/2019-guest_worker/guestworker-without-credits.mp4" ,
|
||||
"encodingFormat": "video/mp4",
|
||||
"videoFrameSize": "1280x1024"
|
||||
},
|
||||
"video": [
|
||||
{
|
||||
"@id": "r:/guest-worker/video/outcome",
|
||||
"@type": "VideoObject",
|
||||
"thumbnailUrl": "/assets\/thumb\/guest_worker04.jpg",
|
||||
"contentUrl": "http://works.rubenvandeven.com/2019-guest_worker/guestworker-without-credits.mp4" ,
|
||||
"encodingFormat": "video/mp4",
|
||||
"videoFrameSize": "1920x1080"
|
||||
},
|
||||
{
|
||||
"@id": "r:/guest-worker/video/process",
|
||||
"@type": "VideoObject",
|
||||
"thumbnailUrl": "/assets\/thumb\/guest_worker05.jpg",
|
||||
"contentUrl": "http://works.rubenvandeven.com/2019-guest_worker/GuestWorker.mp4" ,
|
||||
"encodingFormat": "video/mp4",
|
||||
"videoFrameSize": "1920x1080"
|
||||
}
|
||||
],
|
||||
"author": {
|
||||
"@id": "r:/person/merijn-van-moll",
|
||||
"@type": "Person",
|
||||
|
@ -273,7 +283,7 @@
|
|||
},
|
||||
"startDate": "2020-01-23",
|
||||
"endDate": "2020-01-23",
|
||||
"url": "https://ecp.nl/jaarcongres/kunst-expo-2019/",
|
||||
"url": "https://www.tivolivredenburg.nl/agenda/privacyrede-2019-16-01-2019/",
|
||||
"workFeatured": []
|
||||
},
|
||||
{
|
||||
|
@ -284,7 +294,15 @@
|
|||
"organizer": {"@id": "r:/organisation/ccu"},
|
||||
"location": "Nijverheidsloods, Utrecht"
|
||||
}
|
||||
]
|
||||
],
|
||||
"about": {
|
||||
"@id": "r:/guest-worker/report",
|
||||
"@type": "Report",
|
||||
"name": "Guest Worker Research Report",
|
||||
"description": "A brief report written in light of Guest Worker (2019). In Dutch.",
|
||||
"url": "http://guest_worker.rubenvandeven.com/",
|
||||
"datePublished": "2019-11-26"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -824,6 +842,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"@id": "r:/eye-without-a-face",
|
||||
"@type": "MediaObject",
|
||||
"name": "EYE Without A Face",
|
||||
"dateCreated": "2016",
|
||||
|
@ -852,6 +871,14 @@
|
|||
"thumbnailUrl": "/assets\/thumb\/eye_6-2.jpg"
|
||||
}
|
||||
],
|
||||
"video": {
|
||||
"@id": "r:/eye-without-a-face/video",
|
||||
"@type": "VideoObject",
|
||||
"thumbnailUrl": "/assets\/thumb\/eye_1.jpg",
|
||||
"contentUrl": "http://works.rubenvandeven.com/2016-eye_without_a_face/EyeWithoutAFace.mp4" ,
|
||||
"encodingFormat": "video/mp4",
|
||||
"videoFrameSize": "1920x1080"
|
||||
},
|
||||
"@reverse": {
|
||||
"workFeatured": [
|
||||
{
|
||||
|
@ -1323,7 +1350,7 @@
|
|||
},
|
||||
{
|
||||
"@type": "TheaterEvent",
|
||||
"name": "NEXT Festival",
|
||||
"name": "Winzavod Art Center",
|
||||
"location": "Moscow",
|
||||
"startDate": "2020-02-14",
|
||||
"endDate": "2020-02-28",
|
||||
|
|
Loading…
Reference in a new issue