From 22f766127dc73cc842a6d29ed8f35d9fb325fb60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Lamercerie?= <aurelien.lamercerie@tetras-libre.fr> Date: Fri, 17 Feb 2023 10:53:06 +0100 Subject: [PATCH] dev in progress: uriref_computer --- tenet/febTransduction/uriref_computer.py | 9 +++ tests/test_transduction_prefix_handle.py | 6 +- tests/test_transduction_uriref_computer.py | 70 ++++++++++++++++++++++ 3 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 tests/test_transduction_uriref_computer.py diff --git a/tenet/febTransduction/uriref_computer.py b/tenet/febTransduction/uriref_computer.py index 7bf24cc6..f508fd3e 100644 --- a/tenet/febTransduction/uriref_computer.py +++ b/tenet/febTransduction/uriref_computer.py @@ -14,11 +14,20 @@ from rdflib import URIRef, Graph, RDF, SDO from rdflib.term import _is_valid_uri + +#============================================================================== +# Checking Method(s) +#============================================================================== + class InvalidURIRef(Exception): """Raise when URIs are invalid.""" pass +#============================================================================== +# Main Method(s) +#============================================================================== + def create_uriref(uri): """Create a URIRef with the same validation func used by URIRef diff --git a/tests/test_transduction_prefix_handle.py b/tests/test_transduction_prefix_handle.py index 545ca2f6..5af17c53 100644 --- a/tests/test_transduction_prefix_handle.py +++ b/tests/test_transduction_prefix_handle.py @@ -8,8 +8,7 @@ #============================================================================== import subprocess, os -from rdflib import Graph -from rdflib import Namespace +from rdflib import Graph, Namespace from rdflib.namespace import NamespaceManager FILE_PATH = f'{os.path.dirname(os.path.abspath(__file__))}' @@ -18,11 +17,8 @@ OUTPUT_DIR_PATH = f'{FILE_PATH}/output/' TEST_GRAPH = f'{INPUT_DIR_PATH}testGraph1.ttl' from context import tenet -from tenet.febTransduction import phenomena_application_or as test_rule from tenet.febTransduction import prefix_handle -INDENT_STR = ' ' - #============================================================================== diff --git a/tests/test_transduction_uriref_computer.py b/tests/test_transduction_uriref_computer.py new file mode 100644 index 00000000..fea2b124 --- /dev/null +++ b/tests/test_transduction_uriref_computer.py @@ -0,0 +1,70 @@ +#!/usr/bin/python3.10 +# -*-coding:Utf-8 -* + +#============================================================================== +# TENET: Extraction Rule Test +#------------------------------------------------------------------------------ +# Script to test rules under development +#============================================================================== + +import subprocess, os +from rdflib import Graph, Namespace +from rdflib.namespace import NamespaceManager +from rdflib.term import _is_valid_uri + +FILE_PATH = f'{os.path.dirname(os.path.abspath(__file__))}' +INPUT_DIR_PATH = f'{FILE_PATH}/input/' +OUTPUT_DIR_PATH = f'{FILE_PATH}/output/' +TEST_GRAPH = f'{INPUT_DIR_PATH}testGraph1.ttl' + +from context import tenet +from tenet.febTransduction import uriref_computer + + + +#============================================================================== +# Useful Methods +#============================================================================== + +# None + + +#============================================================================== +# Development Test +#============================================================================== + +def devtest_check_uri(uri): + print(f'\n -- Test URI checking') + print(f' ----- uri: {uri}') + print(f' ----- check 1: {_is_valid_uri(uri)}') + + +#============================================================================== +# Unit Test +#============================================================================== + +# TODO + + + + +#============================================================================== +# Test Script +#============================================================================== + +if __name__ == '__main__': + + print('\n *** Test Preparation ***') + pass + print('\n \n') + + print('\n *** Development Test ***') + devtest_check_uri('<net:compositeClass_orbit_hasManner_conjunction-OR>') + devtest_check_uri('net:compositeClass_orbit_hasManner_conjunction-OR') + print('\n \n') + + print('\n *** Unit Test ***') + pass + print('\n \n') + + print('\n *** - ***') \ No newline at end of file -- GitLab