Skip to content

Commit

Permalink
Fix releases
Browse files Browse the repository at this point in the history
  • Loading branch information
kdouda committed Jan 5, 2025
1 parent 43a7591 commit 0fca14b
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["hatchling"]
requires = ["hatchling==1.26.3"]
build-backend = "hatchling.build"

[project]
Expand Down
2 changes: 1 addition & 1 deletion src/pyrdfrules/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2023-present Karel Douda <kareldouda1@gmail.com>
#
# SPDX-License-Identifier: MIT
__version__ = "0.0.1"
__version__ = "0.0.2"
17 changes: 17 additions & 0 deletions src/pyrdfrules/common/result/result.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

from typing import List
from pyrdfrules.common.rule.resultrule import ResultRule
from pyrdfrules.common.rule.ruleset import Ruleset

Expand All @@ -11,6 +12,8 @@ class Result():
"""Ruleset generated by RDFRules.
"""

predictionTasks: List[dict] = None

data: dict
"""Raw JSON response from RDFRules."""

Expand All @@ -31,6 +34,8 @@ def _parse_data(self):
"""

rules = []
predictionTasks = []
evaluate = []

for item in self.data:
match item:
Expand All @@ -39,11 +44,23 @@ def _parse_data(self):
rule = ResultRule.model_validate(item)
rules.append(rule)
pass

case {'candidates': _, 'predictionTask': __}:
# Item is a prediction task
predictionTasks.append(item)
pass

case {'error': _}:
# Item is an error
print("Error: " + item['error'])
pass

case _:
print("Unknown item")
pass

self.ruleset = Ruleset(rules = rules)
self.predictionTasks = predictionTasks

def get_ruleset(self) -> Ruleset:
"""Returns the ruleset generated by RDFRules.
Expand Down
117 changes: 117 additions & 0 deletions src/tests/data/evaluate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
[
{
"name": "LoadGraph",
"parameters": {
"path": "/data/wn18rr/train.tsv",
"settings": "tsvParsedUris"
}
},
{
"name": "Index",
"parameters": {
"train": [],
"test": []
}
},
{
"name": "Mine",
"parameters": {
"thresholds": [
{
"name": "MinHeadSize",
"value": 1
},
{
"name": "MinSupport",
"value": 5
},
{
"name": "MaxRuleLength",
"value": 3
}
],
"ruleConsumers": [
{
"name": "topK",
"k": 10000,
"allowOverflow": true
}
],
"patterns": [],
"constraints": [
{
"name": "OnlyLowerCardinalitySideConstants"
}
],
"parallelism": 0
}
},
{
"name": "ComputeConfidence",
"parameters": {
"name": "QpcaConfidence",
"min": 0.2
}
},
{
"name": "SortRuleset",
"parameters": {
"by": []
}
},
{
"name": "Prune",
"parameters": {
"strategy": "DataCoveragePruning",
"onlyFunctionalProperties": false,
"onlyExistingTriples": true,
"injectiveMapping": true
}
},
{
"name": "Predict",
"parameters": {
"rules": [],
"chooseTestSet": true,
"testPath": "/data/wn18rr/test.tsv",
"predictedResults": [],
"headVariablePreMapping": {
"type": "noMapping"
},
"injectiveMapping": true,
"mergeTestAndTrainForPrediction": true,
"onlyTestCoveredPredictions": false
}
},
{
"name": "GroupPredictions",
"parameters": {
"useScorer": true,
"scorer": {
"type": "maximum",
"confidence": "default"
},
"useConsumer": false,
"confidence": "default"
}
},
{
"name": "ToPredictionTasks",
"parameters": {
"confidence": "default",
"generator": {
"type": "testCardinalities"
}
}
},
{
"name": "WithModes",
"parameters": {}
},
{
"name": "Evaluate",
"parameters": {
"ranking": "test"
}
}
]

0 comments on commit 0fca14b

Please sign in to comment.