This repository has been archived by the owner on Sep 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 47f8ba2
Showing
28 changed files
with
1,224 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,176 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>FörderFunke</title> | ||
<script src="./bundle.js"></script> | ||
<link rel="stylesheet" href="./choices.min.css" /> | ||
<script src="./choices.min.js"></script> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
} | ||
.loadingDiv { | ||
color: gray; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h3>User profile</h3> | ||
<div id="userProfileDiv"></div> | ||
<h3>Missing data points</h3> | ||
<div>Set a focus:</div> | ||
<br/> | ||
<select id="focusInputSelectElement" multiple></select> | ||
<div class="loadingDiv">Loading...</div> | ||
<div id="missingDataPointsDiv"></div> | ||
<h3>Report</h3> | ||
<div class="loadingDiv">Loading...</div> | ||
<table id="reportTable"></table> | ||
|
||
<script> | ||
const element = document.getElementById("focusInputSelectElement") | ||
const focusInputSelect = new Choices(element, { | ||
removeItemButton: true, | ||
position: "bottom", | ||
placeholderValue: "No focus set --> prioritization of missing data points goes over all requirement profiles", | ||
}); | ||
|
||
let turtleMap | ||
let metadata | ||
let validateAllReport | ||
|
||
let userProfile = ` | ||
@prefix ff: <https://foerderfunke.org/default#> . | ||
ff:mainPerson a ff:Citizen . | ||
` | ||
|
||
async function fetchTextFile(relPath) { | ||
const response = await fetch(relPath) | ||
return await response.text() | ||
} | ||
|
||
async function loadFiles() { | ||
let turtleMap = { | ||
"datafields": await fetchTextFile("requirement-profiles/datafields.ttl"), | ||
"materialization": await fetchTextFile("requirement-profiles/materialization.ttl"), | ||
"shacl": {} | ||
} | ||
let shaclFiles = await fetchTextFile("shacl-files.txt") | ||
for (let filename of shaclFiles.split("\n")) { | ||
if (!filename) continue | ||
turtleMap.shacl[filename] = await fetchTextFile("requirement-profiles/shacl/" + filename) | ||
} | ||
return turtleMap | ||
} | ||
|
||
async function fetchMetadata() { | ||
metadata = { | ||
df: await MatchingEngine.extractDatafieldsMetadata(turtleMap.datafields), | ||
rp: await MatchingEngine.extractRequirementProfilesMetadata(Object.values(turtleMap.shacl)) | ||
} | ||
console.log("metadata", metadata) | ||
} | ||
|
||
function buildFocusInputSelectChoices() { | ||
// TODO | ||
|
||
focusInputSelect.setChoices([ | ||
{ | ||
label: "GroupA", | ||
choices: [ | ||
{value: "foo", label: "Foo"}, | ||
{value: "bar", label: "Bar"}, | ||
] | ||
}, | ||
{ | ||
label: "GroupB", | ||
choices: [ | ||
{value: "hey", label: "Hey"}, | ||
{value: "jo", label: "Jo"}, | ||
] | ||
}, | ||
]) | ||
} | ||
|
||
async function validateAll() { | ||
document.getElementById("userProfileDiv").textContent = userProfile | ||
|
||
validateAllReport = await MatchingEngine.validateAll(userProfile, turtleMap.shacl, turtleMap.datafields, turtleMap.materialization) | ||
console.log("validateAllReport", validateAllReport) | ||
|
||
for (let report of validateAllReport.reports) { | ||
let tr = document.createElement("tr") | ||
let td = document.createElement("td") | ||
td.textContent = metadata.rp[report.rpUri]?.title ?? report.rpUri | ||
tr.appendChild(td) | ||
td = document.createElement("td") | ||
td.textContent = report.result | ||
tr.appendChild(td) | ||
document.getElementById("reportTable").appendChild(tr) | ||
} | ||
|
||
buildPrioritizedMissingDataList() | ||
} | ||
|
||
function buildPrioritizedMissingDataList() { | ||
let div = document.getElementById("missingDataPointsDiv") | ||
div.textContent = "" | ||
let prioritizedList = [] | ||
|
||
let missingData = validateAllReport.missingUserInputsAggregated | ||
|
||
for (let key of Object.keys(missingData)) { | ||
let datafield = missingData[key] | ||
let usedInTitles = [] | ||
let lastMissingCounter = 0 | ||
for (let usedInRP of datafield.usedIn) { | ||
usedInTitles.push(metadata.rp[usedInRP.rpUri].title + (usedInRP.isLastMissingUserInput ? " (!)" : "")) | ||
if (usedInRP.isLastMissingUserInput) lastMissingCounter += 1 | ||
} | ||
prioritizedList.push({ | ||
dfUri: datafield.dfUri, | ||
label: metadata.df[datafield.dfUri]?.label ?? datafield.dfUri.split("#")[1], | ||
score: datafield.usedIn.length + lastMissingCounter, | ||
usedInTitles: usedInTitles | ||
}) | ||
} | ||
prioritizedList.sort((a, b) => b.score - a.score) | ||
prioritizedList.forEach((entry) => { | ||
let spanEl = document.createElement("span") | ||
spanEl.title = entry.usedInTitles.join("\n") | ||
let textNode = document.createTextNode(entry.score + ": ") | ||
spanEl.appendChild(textNode) | ||
div.appendChild(spanEl) | ||
let a = document.createElement("a") | ||
a.href = "#" | ||
a.textContent = entry.label | ||
a.addEventListener("click", function(event) { | ||
event.preventDefault() | ||
let input = prompt("What is your value for: " + entry.label) | ||
if (input !== null) { | ||
console.log(entry.dfUri, "-->", input) | ||
// TODO | ||
} | ||
}); | ||
div.appendChild(a) | ||
div.appendChild(document.createElement("br")) | ||
}); | ||
for (const elem of Array.from(document.getElementsByClassName("loadingDiv"))) { | ||
elem.style.display = "none" | ||
} | ||
} | ||
|
||
async function run() { | ||
turtleMap = await loadFiles() | ||
await fetchMetadata() | ||
await validateAll() | ||
// buildFocusInputSelectChoices() | ||
} | ||
|
||
run() | ||
|
||
</script> | ||
</body> | ||
</html> |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 FörderFunke | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 @@ | ||
# requirement-profiles | ||
Requirement profiles, details about datafields and materialization queries. | ||
|
||
Used in the [foerderfunke-app](https://github.com/Citizen-Knowledge-Graph/foerderfunke-app) and for developing the [matching-engine](https://github.com/Citizen-Knowledge-Graph/matching-engine). |
Oops, something went wrong.