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

Refine heuristic rule: relation_deducer_1

parent 5645d741
Branches
No related tags found
No related merge requests found
Showing
with 58 additions and 40 deletions
...@@ -118,6 +118,7 @@ def __construct_atom_class_net(graph, leaf, concept_name): ...@@ -118,6 +118,7 @@ def __construct_atom_class_net(graph, leaf, concept_name):
# -- Finalization # -- Finalization
atom_class_net.finalize() atom_class_net.finalize()
atom_class_net.root_class_net = atom_class_net.uri
triple_definition = atom_class_net.generate_triple_definition() triple_definition = atom_class_net.generate_triple_definition()
return atom_class_net, triple_definition return atom_class_net, triple_definition
......
...@@ -106,6 +106,7 @@ def __construct_composite_class_net( ...@@ -106,6 +106,7 @@ def __construct_composite_class_net(
# -- Data Computation # -- Data Computation
composite_class_net.mother_class_net = base_class_net.uri composite_class_net.mother_class_net = base_class_net.uri
composite_class_net.root_class_net = base_class_net.root_class_net
# -- Restriction Computation # -- Restriction Computation
restriction_net, triple_list_1 = __construct_restriction_net(graph, core_property_net, target_class_net) restriction_net, triple_list_1 = __construct_restriction_net(graph, core_property_net, target_class_net)
......
...@@ -105,6 +105,7 @@ def __construct_composite_class_net( ...@@ -105,6 +105,7 @@ def __construct_composite_class_net(
# -- Data Computation # -- Data Computation
composite_class_net.mother_class_net = base_class_net.uri composite_class_net.mother_class_net = base_class_net.uri
composite_class_net.root_class_net = base_class_net.root_class_net
# -- Restriction Computation # -- Restriction Computation
restriction_net, triple_list_1 = __construct_restriction_net(graph, core_property_net, target_class_net) restriction_net, triple_list_1 = __construct_restriction_net(graph, core_property_net, target_class_net)
......
...@@ -134,8 +134,9 @@ def __construct_composite_class_net( ...@@ -134,8 +134,9 @@ def __construct_composite_class_net(
composite_class_net.compose(base_class_net, core_property_net, target_class_net) composite_class_net.compose(base_class_net, core_property_net, target_class_net)
# -- Data Computation # -- Data Computation
composite_class_net.mother_class_net = [base_class_net.uri, mother_class_net.uri] # composite_class_net.mother_class_net = [base_class_net.uri, mother_class_net.uri]
composite_class_net.mother_class_net = [mother_class_net.uri] composite_class_net.mother_class_net = mother_class_net.uri
composite_class_net.root_class_net = base_class_net.root_class_net
# -- Restriction Computation # -- Restriction Computation
restriction_net, triple_list_1 = __construct_restriction_net(graph, core_property_net, target_class_net) restriction_net, triple_list_1 = __construct_restriction_net(graph, core_property_net, target_class_net)
......
...@@ -79,13 +79,13 @@ def __get_structure(graph): ...@@ -79,13 +79,13 @@ def __get_structure(graph):
return structure return structure
def __define_individual_label(net): def __define_individual_label(net, reference):
class_label = 'thing' class_label = 'thing'
naming_list = net.naming naming_list = net.naming
if len(naming_list) > 0: if len(naming_list) > 0:
assert len(naming_list) == 1, 'Houston, we have a problem: too many naming' assert len(naming_list) == 1, 'Houston, we have a problem: too many naming'
class_label = naming_list[0] class_label = naming_list[0]
return f'any {class_label}' return f'{class_label} ({reference})'
...@@ -99,15 +99,15 @@ def __construct_individual_net(graph, mother_class_net): ...@@ -99,15 +99,15 @@ def __construct_individual_net(graph, mother_class_net):
individual_net = net.IndividualNet(graph) individual_net = net.IndividualNet(graph)
# -- Main mother class # -- Main mother class
main_mother_class_net = mother_class_net root_class_net = mother_class_net
if mother_class_net.mother_class_net: if mother_class_net.root_class_net:
main_mother_class_net = net.ClassNet(graph, uri=mother_class_net.mother_class_net[0]) root_class_net = net.ClassNet(graph, uri=mother_class_net.root_class_net[0])
# -- Data Computation # -- Data Computation
individual_net.base_node = mother_class_net.base_node individual_net.base_node = mother_class_net.base_node
individual_net.node = mother_class_net.node individual_net.node = mother_class_net.node
individual_net.individual_label = __define_individual_label(main_mother_class_net)
structure_ref = __get_structure(graph) structure_ref = __get_structure(graph)
individual_net.individual_label = __define_individual_label(root_class_net, structure_ref)
individual_net.structure = structure_ref individual_net.structure = structure_ref
# -- Mother classes # -- Mother classes
...@@ -118,7 +118,7 @@ def __construct_individual_net(graph, mother_class_net): ...@@ -118,7 +118,7 @@ def __construct_individual_net(graph, mother_class_net):
individual_net.mother_class_net = mother_class_net_list individual_net.mother_class_net = mother_class_net_list
# -- Net Naming # -- Net Naming
individual_net.naming = define_individual_naming(main_mother_class_net, structure_ref) individual_net.naming = define_individual_naming(root_class_net, structure_ref)
# -- Finalization # -- Finalization
individual_net.finalize() individual_net.finalize()
......
...@@ -108,6 +108,7 @@ def __construct_composite_class_net(graph, class_net_1, class_net_2): ...@@ -108,6 +108,7 @@ def __construct_composite_class_net(graph, class_net_1, class_net_2):
# -- Data Computation # -- Data Computation
composite_class_net.mother_class_net = class_net_1.uri composite_class_net.mother_class_net = class_net_1.uri
composite_class_net.root_class_net = class_net_1.root_class_net
# -- Restriction Computation # -- Restriction Computation
triple_list_1 = [] triple_list_1 = []
...@@ -136,7 +137,7 @@ def __construct_individual_net(graph, class_net): ...@@ -136,7 +137,7 @@ def __construct_individual_net(graph, class_net):
individual_net.compose(class_net) individual_net.compose(class_net)
# -- Data Computation # -- Data Computation
individual_net.base_class_name = f'Feature' individual_net.base_class_name = 'Feature'
individual_net.mother_class_net = class_net.uri individual_net.mother_class_net = class_net.uri
# -- Net Naming # -- Net Naming
......
...@@ -118,6 +118,7 @@ def __construct_composite_class_net_from_3_nets( ...@@ -118,6 +118,7 @@ def __construct_composite_class_net_from_3_nets(
# -- Data Computation # -- Data Computation
composite_class_net.mother_class_net = base_class_net.uri composite_class_net.mother_class_net = base_class_net.uri
composite_class_net.root_class_net = base_class_net.root_class_net
# -- Restriction Computation # -- Restriction Computation
restriction_net, triple_list_1 = __construct_restriction_net(graph, core_property_net, target_class_net) restriction_net, triple_list_1 = __construct_restriction_net(graph, core_property_net, target_class_net)
...@@ -139,27 +140,27 @@ def __construct_composite_class_net_from_3_nets( ...@@ -139,27 +140,27 @@ def __construct_composite_class_net_from_3_nets(
def __construct_class_union_net(graph, base_class_net, class_net_list): # def __construct_class_union_net(graph, base_class_net, class_net_list):
# -- Net Composition # # -- Net Composition
class_union_net = net.PropertyUnionNet(graph) # class_union_net = net.PropertyUnionNet(graph)
class_union_net.compose(base_class_net, class_net_list) # class_union_net.compose(base_class_net, class_net_list)
# -- Data Computation: None # # -- Data Computation: None
# -- Restriction Computation: None # # -- Restriction Computation: None
# -- Relation Propagation # # -- Relation Propagation
__propagate_relation(class_union_net, base_class_net) # __propagate_relation(class_union_net, base_class_net)
# -- Net Naming # # -- Net Naming
class_union_net.naming = define_union_naming(base_class_net) # class_union_net.naming = define_union_naming(base_class_net)
# -- Finalization # # -- Finalization
class_union_net.finalize() # class_union_net.finalize()
triple_list = class_union_net.generate_triple_definition() # triple_list = class_union_net.generate_triple_definition()
return class_union_net, triple_list # return class_union_net, triple_list
#============================================================================== #==============================================================================
......
...@@ -140,27 +140,27 @@ def __construct_composite_property_net_from_3_properties( ...@@ -140,27 +140,27 @@ def __construct_composite_property_net_from_3_properties(
def __construct_property_union_net(graph, base_property_net, property_net_list): # def __construct_property_union_net(graph, base_property_net, property_net_list):
# -- Net Composition # # -- Net Composition
property_union_net = net.PropertyUnionNet(graph) # property_union_net = net.PropertyUnionNet(graph)
property_union_net.compose(base_property_net, property_net_list) # property_union_net.compose(base_property_net, property_net_list)
# -- Data Computation: None # # -- Data Computation: None
# -- Restriction Computation: None # # -- Restriction Computation: None
# -- Relation Propagation # # -- Relation Propagation
__propagate_relation(property_union_net, base_property_net) # __propagate_relation(property_union_net, base_property_net)
# -- Net Naming # # -- Net Naming
property_union_net.naming = define_union_naming(base_property_net) # property_union_net.naming = define_union_naming(base_property_net)
# -- Finalization # # -- Finalization
property_union_net.finalize() # property_union_net.finalize()
triple_list = property_union_net.generate_triple_definition() # triple_list = property_union_net.generate_triple_definition()
return property_union_net, triple_list # return property_union_net, triple_list
......
...@@ -34,11 +34,12 @@ class ClassNet(Net): ...@@ -34,11 +34,12 @@ class ClassNet(Net):
self.type_uri = produce_uriref(self.support_graph, f'net:{self.type_id}') self.type_uri = produce_uriref(self.support_graph, f'net:{self.type_id}')
# -- Net Attributes # -- Net Attributes
self.attr_list += ['class_name', 'class_uri', 'class_type', 'mother_class_net'] self.attr_list += ['class_name', 'class_uri', 'class_type', 'mother_class_net', 'root_class_net']
self._class_name = None self._class_name = None
self._class_uri = None self._class_uri = None
self._class_type = None self._class_type = None
self._mother_class_net = None self._mother_class_net = None
self._root_class_net = None
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
...@@ -86,3 +87,13 @@ class ClassNet(Net): ...@@ -86,3 +87,13 @@ class ClassNet(Net):
@mother_class_net.setter @mother_class_net.setter
def mother_class_net(self, new_value): def mother_class_net(self, new_value):
self._mother_class_net = self.set_attribute_value_list(new_value, produce_uriref) self._mother_class_net = self.set_attribute_value_list(new_value, produce_uriref)
@property
def root_class_net(self):
if self._root_class_net is None:
self._root_class_net = self.get_value_list_from_graph('root_class_net')
return self._root_class_net
@root_class_net.setter
def root_class_net(self, new_value):
self._root_class_net = self.set_attribute_value_list(new_value, produce_uriref)
\ No newline at end of file
...@@ -39,6 +39,7 @@ class SemanticNetReferenceHandle: ...@@ -39,6 +39,7 @@ class SemanticNetReferenceHandle:
# Class Net # Class Net
'class_name': 'hasClassName', 'class_name': 'hasClassName',
'mother_class_net': 'hasMotherClassNet', 'mother_class_net': 'hasMotherClassNet',
'root_class_net': 'hasRootClassNet',
'class_type': 'hasClassType', 'class_type': 'hasClassType',
# Property Net # Property Net
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment