Skip to content

Commit

Permalink
Refine the materialization concept again
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminaaron committed May 1, 2024
1 parent efc71bf commit a6e4f2c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions dev/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ async function devValidateAll() {

let requirementProfiles = {}
for (let file of shaclFiles) {
// if (!(file === "kinderzuschlag.ttl")) continue
requirementProfiles[file] = await fsPromise.readFile(`${SHACL_DIR}/${file}`, "utf8")
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@foerderfunke/matching-engine",
"version": "0.3.3",
"version": "0.3.4",
"description": "Checks eligibilities by validating a user profile against requirement profiles",
"author": "@foerderfunke",
"license": "MIT",
Expand Down
14 changes: 9 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,9 @@ export async function validateOne(userProfile, requirementProfile, datafieldsStr
let askUserForDataPoints = []

// ----- for the ones we can't materialize we need user input -----
// this is one-dimensional so far, only predicates directly at mainPerson are possible TODO
// and we should tell the user that for instance either hasAge (rule output) or hasBirthday (rule input) is missing TOOD
// we should tell the user that for instance either hasAge (rule output) or hasBirthday (rule input) is missing TODO

// get all predicates directly attached to mainPerson
// get all predicates directly attached to mainPerson, this is one-dimensional TODO
let query = `
PREFIX ff: <https://foerderfunke.org/default#>
SELECT DISTINCT ?predicate WHERE {
Expand All @@ -147,8 +146,13 @@ export async function validateOne(userProfile, requirementProfile, datafieldsStr

for (let missing of missingList) {
let matchingRule = materializableDataPoints.find(n => n.output === missing.predicate)
// we can only use a materialization rule that outputs our missing data point, if we have the input for this rule
if (matchingRule && existingMainPersonPredicates.includes(matchingRule.input)) continue
let otherRuleWithThatInputAsOutput = undefined
if (matchingRule && matchingRule.input) {
otherRuleWithThatInputAsOutput = materializableDataPoints.find(n => n.output === matchingRule.input)
}
// quite annoying to check all these options, maybe another approach also removing the need for topological sorting? TODO
// I am thinking of rounds of materialization: in each we look what's possible, and we do it until no rule triggers anymore
if (matchingRule && (!matchingRule.input || otherRuleWithThatInputAsOutput || existingMainPersonPredicates.includes(matchingRule.input))) continue
askUserForDataPoints.push(missing)
}

Expand Down

0 comments on commit a6e4f2c

Please sign in to comment.