Coverage for lode / models / concept.py: 84%

76 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-10-05 16:02 +0000

1from .resource import Resource 

2 

3class Concept(Resource): 

4 

5 def __init__(self, **kwargs): 

6 

7 super().__init__(**kwargs) 

8 

9 # Relations with Concepts 

10 self.is_sub_concept_of = [] # 0..* 

11 self.is_super_concept_of = [] # 0..* 

12 self.is_disjoint_with = [] # 0..* 

13 self.is_equivalent_to = [] # 0..* 

14 self.is_related_to = [] # 0..* 

15 self.has_broad_match = [] # 0..* 

16 self.has_narrow_match = [] # 0..* 

17 self.has_related_match = [] # 0..* 

18 self.has_exact_match = [] # 0..*  

19 self.has_close_match = [] # 0..* 

20 self.has_key = [] # 0..* 

21 self.individuals_with_this_type = [] # 0..* (inverso di Individual.has_type) 

22 self.is_in_domain_of = [] # 0..* 

23 

24 

25 def set_has_key(self, prop): 

26 self.has_key.append(prop) 

27 

28 def get_has_key(self): 

29 return self.has_key 

30 

31 # Setter e Getter per is_sub_concept_of 

32 def set_is_sub_concept_of(self, concept): 

33 if concept not in self.is_sub_concept_of: 

34 self.is_sub_concept_of.append(concept) 

35 # inverso: solo se il target supporta la relazione (es. Restriction/TruthFunction potrebbero non averlo) 

36 inv = getattr(concept, 'is_super_concept_of', None) 

37 if inv is not None and self not in inv: 

38 inv.append(self) 

39 

40 def set_is_super_concept_of(self, concept): 

41 if concept not in self.is_super_concept_of: 

42 self.is_super_concept_of.append(concept) 

43 

44 def get_is_super_concept_of(self): 

45 return self.is_super_concept_of 

46 

47 def get_is_sub_concept_of(self): 

48 """Restituisce la lista is_sub_concept_of""" 

49 return self.is_sub_concept_of 

50 

51 # Setter e Getter per is_disjoint_with 

52 def set_is_disjoint_with(self, concept): 

53 """Aggiunge un Concept a is_disjoint_with""" 

54 self.is_disjoint_with.append(concept) 

55 

56 def get_is_disjoint_with(self): 

57 """Restituisce la lista is_disjoint_with""" 

58 return self.is_disjoint_with 

59 

60 # Setter e Getter per is_equivalent_to 

61 def set_is_equivalent_to(self, concept): 

62 """Aggiunge un Concept a is_equivalent_to""" 

63 self.is_equivalent_to.append(concept) 

64 

65 def get_is_equivalent_to(self): 

66 """Restituisce la lista is_equivalent_to""" 

67 return self.is_equivalent_to 

68 

69 # Setter e Getter per is_related_to 

70 def set_is_related_to(self, concept): 

71 """Aggiunge un Concept a is_related_to""" 

72 self.is_related_to.append(concept) 

73 

74 def get_is_related_to(self): 

75 """Restituisce la lista is_related_to""" 

76 return self.is_related_to 

77 

78 # Setter e Getter per has_broad_match 

79 def set_has_broad_match(self, concept): 

80 """Aggiunge un Concept a has_broad_match""" 

81 self.has_broad_match.append(concept) 

82 

83 def get_has_broad_match(self): 

84 """Restituisce la lista has_broad_match""" 

85 return self.has_broad_match 

86 

87 # Setter e Getter per has_narrow_match 

88 def set_has_narrow_match(self, concept): 

89 """Aggiunge un Concept a has_narrow_match""" 

90 self.has_narrow_match.append(concept) 

91 

92 def get_has_narrow_match(self): 

93 """Restituisce la lista has_narrow_match""" 

94 return self.has_narrow_match 

95 

96 # Setter e Getter per has_related_match 

97 def set_has_related_match(self, concept): 

98 """Aggiunge un Concept a has_related_match""" 

99 self.has_related_match.append(concept) 

100 

101 def get_has_related_match(self): 

102 """Restituisce la lista has_related_match""" 

103 return self.has_related_match 

104 

105 # Setter e Getter per has_exact_match 

106 def set_has_exact_match(self, concept): 

107 """Aggiunge un Concept a has_exact_match""" 

108 self.has_exact_match.append(concept) 

109 

110 def get_has_exact_match(self): 

111 """Restituisce la lista has_exact_match""" 

112 return self.has_exact_match 

113 

114 # Setter e Getter per has_close_match 

115 def set_has_close_match(self, concept): 

116 """Aggiunge un Concept a has_close_match""" 

117 self.has_close_match.append(concept) 

118 

119 def get_has_close_match(self): 

120 """Restituisce la lista has_close_match""" 

121 return self.has_close_match 

122 

123 def set_individuals_with_this_type(self, individual): 

124 """Aggiunge un Individual a individuals_with_this_type (inverso di rdf:type).""" 

125 if individual not in self.individuals_with_this_type: 

126 self.individuals_with_this_type.append(individual) 

127 

128 def get_individuals_with_this_type(self): 

129 """Restituisce la lista individuals_with_this_type.""" 

130 return list(self.individuals_with_this_type) 

131 

132 def set_is_in_domain_of(self, prop): 

133 if prop not in self.is_in_domain_of: 

134 self.is_in_domain_of.append(prop) 

135 

136 def get_is_in_domain_of(self): 

137 return list(self.is_in_domain_of) 

138