Skip to content
Snippets Groups Projects
Commit 234a74a8 authored by Aurélien Lamercerie's avatar Aurélien Lamercerie
Browse files

Delete old query building module

parent aa795f92
No related branches found
No related tags found
No related merge requests found
......@@ -490,19 +490,19 @@ if __name__ == '__main__':
print('\n' + ' -- test: update a test query')
test_query= f"""[...]
CONSTRUCT {{
{atom_class_net.construct('?node1',
structure='?structureRef',
class_name='?leaf1ConceptLabel')}
{atom_class_net.construct(base_node='{{node1.id}}',
structure='{{structure.sentence_ref}}',
class_name='{{node1.concept_label}}')}
{atom_class_net.propagate_relations()}
}}
WHERE {{
{{node.identify()}}
?concept rdfs:subClassOf amr:AMR_Term_Concept.
?concept amr:label ?conceptName.
?variable amr:label ?varLabel.
{{node1.identify(type='AMR_Term_Concept')}}
{{node1.concept}} rdfs:subClassOf amr:AMR_Term_Concept.
{{node1.concept}} amr:label ?conceptName.
{{node1.variable}} amr:label ?varLabel.
{{structure.identify()}}
......
#!/usr/bin/python3.10
# -*-coding:Utf-8 -*
#==============================================================================
# TENET: Binding Query Builder
#------------------------------------------------------------------------------
# Module offering different functions to build SPARQL queries of transduction
# rules, for binding query part.
#==============================================================================
#==============================================================================
# Importing required modules
#==============================================================================
# --
#==============================================================================
# Data Repository
#==============================================================================
# -- Default References
DEFAULT_NET_ID = '?newNet'
DEFAULT_NET_TYPE = 'Net'
DEFAULT_SENTENCE_REF = '?sentenceRef'
DEFAULT_BASE_LEAF = '?baseLeaf'
DEFAULT_CLASS_NAME = '?className'
# -- Reference Table
DATA_PROPERTY_TABLE = {
'sentence_ref': 'hasStructure',
'class_name': 'hasClassName',
'mother_class_net': 'hasMotherClassNet',
'individual_label': 'hasIndividualLabel'
}
#==============================================================================
# Useful Functions
#==============================================================================
# --
#==============================================================================
# Main Functions
#==============================================================================
def new_variable(id):
return f"*** new_variable(id) ***"
#==============================================================================
# Development Test
#==============================================================================
if __name__ == '__main__':
print('\n' + ' *** Development Test ***')
print('\n' + ' -- test: todo')
print('\n' + ' *** - ***')
\ No newline at end of file
#!/usr/bin/python3.10
# -*-coding:Utf-8 -*
#==============================================================================
# TENET: Clause Query Builder
#------------------------------------------------------------------------------
# Module offering different functions to build SPARQL queries of transduction
# rules, for clause query part.
#==============================================================================
#==============================================================================
# Importing required modules
#==============================================================================
# --
#==============================================================================
# Data Repository
#==============================================================================
# -- Default References
DEFAULT_NET_ID = '?newNet'
DEFAULT_NET_TYPE = 'Net'
DEFAULT_SENTENCE_REF = '?sentenceRef'
DEFAULT_BASE_LEAF = '?baseLeaf'
DEFAULT_CLASS_NAME = '?className'
# -- Reference Table
DATA_PROPERTY_TABLE = {
'sentence_ref': 'hasStructure',
'class_name': 'hasClassName',
'mother_class_net': 'hasMotherClassNet',
'individual_label': 'hasIndividualLabel'
}
#==============================================================================
# Useful Functions
#==============================================================================
# --
#==============================================================================
# Main Functions
#==============================================================================
def identify_node(concept, variable):
return f"*** identify_node(concept, variable) ***"
def identify_structure():
return f"*** identify_structure ***"
def identify_relations_for_propagation(net_id):
return f"*** identify_relations_for_propagation()***"
#==============================================================================
# Development Test
#==============================================================================
if __name__ == '__main__':
print('\n' + ' *** Development Test ***')
print('\n' + ' -- test: todo')
print('\n' + ' *** - ***')
\ No newline at end of file
#!/usr/bin/python3.10
# -*-coding:Utf-8 -*
#==============================================================================
# TENET: Construct Query Builder
#------------------------------------------------------------------------------
# Module offering different functions to build SPARQL queries of transduction
# rules, for construct query part.
#==============================================================================
#==============================================================================
# Importing required modules
#==============================================================================
# --
#==============================================================================
# Data Repository
#==============================================================================
# -- Default References
DEFAULT_NET_ID = '?newNet'
DEFAULT_NET_TYPE = 'Net'
DEFAULT_SENTENCE_REF = '?sentenceRef'
DEFAULT_BASE_LEAF = '?baseLeaf'
DEFAULT_CLASS_NAME = '?className'
# -- Reference Table
DATA_PROPERTY_TABLE = {
'sentence_ref': 'hasStructure',
'class_name': 'hasClassName',
'mother_class_net': 'hasMotherClassNet',
'individual_label': 'hasIndividualLabel'
}
#==============================================================================
# Useful Functions
#==============================================================================
def get_net_type(net_type):
if not net_type.startswith('net:'):
net_type = f'net:{net_type}'
return net_type
def get_data_property(data_ref):
property_name = DATA_PROPERTY_TABLE[f'{data_ref}']
return f'net:{property_name}'
def get_net_data(net_id, **net_data):
data_str = ""
for data_ref, data_val in net_data.items():
data_property = get_data_property(data_ref)
data_str += f"{net_id} {data_property} {data_val}.\n "
return data_str
#==============================================================================
# Main Functions
#==============================================================================
def new_net(net_id=DEFAULT_NET_ID,
net_type=DEFAULT_NET_TYPE,
base_leaf=DEFAULT_BASE_LEAF,
**net_data ):
return f"""
# -- New Class Net
{net_id} a {get_net_type(net_type)}.
{net_id} net:coverBaseNode {base_leaf}.
{get_net_data(net_id, **net_data)}"""
def relation_propagation(net_id=DEFAULT_NET_ID):
return f"""
# -- Propagation of relations (from nodes to nets)
?inRelationRole a net:Relation.
?inNet ?inRelationRole {net_id}.
?outRelationRole a net:Relation.
{net_id} ?outRelationRole ?outNet."""
#==============================================================================
# Development Test
#==============================================================================
if __name__ == '__main__':
print('\n' + ' *** Development Test ***')
print('\n' + ' -- test: get_net_data()')
test_str = get_net_data('?newNet', class_name='?conceptName')
print(test_str)
print('\n' + ' -- test: new_net')
test_str = new_net(class_name='?conceptName')
print(test_str)
test_str = new_net(net_type='Atom_Class_Net', class_name='?conceptName')
print(test_str)
print('\n' + ' -- test: update a test query')
test_query= f"""[...]
CONSTRUCT {{
{new_net(net_type='Atom_Class_Net',
sentence_ref='?sentenceRef',
class_name='?conceptName')}
{relation_propagation()}
}}
WHERE {{
clause_1
clause_2
[...]
binding
}}
"""
print(test_query)
print('\n' + ' *** - ***')
\ No newline at end of file
......@@ -66,7 +66,7 @@
- DEBUG - --- Export work graph as turtle
- DEBUG - ----- Work graph file: ./output/SolarSystemDev1-20221214/SolarSystemDev1-1/SolarSystemDev1.ttl
- DEBUG - --- Ending Structure Preparation
- DEBUG - ----- Total Execution Time = 0:00:00.116396
- DEBUG - ----- Total Execution Time = 0:00:00.201392
- INFO - -- Loading Extraction Scheme (amr_scheme_1)
- DEBUG - ----- Step number: 3
- INFO - -- Loading Extraction Rules (amr_ctr/*)
......@@ -216,8 +216,8 @@
- INFO -
*** Execution Time ***
----- Function: apply (lib.tenet_extraction)
----- Total Time: 0:00:06.149423
----- Process Time: 0:00:06.139959
----- Total Time: 0:00:08.164996
----- Process Time: 0:00:08.033522
*** - ***
- INFO - === Final Ontology Generation ===
- INFO - -- Making complete factoid graph by merging sentence factoid graphs
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment