Coverage for lode / models / individual.py: 86%
14 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-11-22 15:54 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-11-22 15:54 +0000
1"""Individual: an OWL named individual."""
2from .resource import Resource
4class Individual(Resource):
5 """
6 Represents an individual instance of a class (owl:NamedIndividual).
7 Extends Resource with the relations specific to OWL individuals.
8 """
10 def __init__(self, **kwargs):
11 """Create an individual with empty is_same_as and is_different_from lists."""
12 super().__init__(**kwargs)
14 # Relations with Individual
15 self.is_same_as = [] # 0..*
16 self.is_different_from = [] # 0..*
17 # Relations with Concept (inherited but made explicit here, because the cardinality changes)
18 # self.has_type = [] # 1..*
20 # def get_has_type(self):
21 # return list(self.has_type)
23 # def set_has_type(self, concept):
24 # self.has_type.append(concept)
26 def get_is_same_as(self):
27 """Return a copy of is_same_as [0..*]."""
28 return list(self.is_same_as)
30 def set_is_same_as(self, individual):
31 """Add an individual to is_same_as [0..*]."""
32 self.is_same_as.append(individual)
34 def get_is_different_from(self):
35 """Return a copy of is_different_from [0..*]."""
36 return list(self.is_different_from)
38 def set_is_different_from(self, individual):
39 """Add an individual to is_different_from [0..*]."""
40 self.is_different_from.append(individual)