diff --git a/dev/dev.js b/dev/dev.js index bfcaf29..3dc7d19 100644 --- a/dev/dev.js +++ b/dev/dev.js @@ -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") } diff --git a/package.json b/package.json index 86fbed5..abc70b3 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.js b/src/index.js index b6b2040..a8be2ef 100644 --- a/src/index.js +++ b/src/index.js @@ -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: SELECT DISTINCT ?predicate WHERE { @@ -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) }