Coverage for lode / models / rule.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-11-22 15:54 +0000

1"""Rule: a SWRL rule.""" 

2from .resource import Resource 

3 

4class Rule(Resource): 

5 """A SWRL rule: when every antecedent atom holds, the consequent atoms hold.""" 

6 

7 def __init__(self, **kwargs): 

8 """Create a rule with no antecedent and no consequent.""" 

9 super().__init__(**kwargs) 

10 self.has_antecedent = [] # Atom [1..*] 

11 self.has_consequent = [] # Atom [1..*] 

12 

13 def get_has_antecedent(self): 

14 """Return a copy of has_antecedent.""" 

15 return list(self.has_antecedent) 

16 

17 def set_has_antecedent(self, atom): 

18 """Add an atom to has_antecedent.""" 

19 self.has_antecedent.append(atom) 

20 

21 def get_has_consequent(self): 

22 """Return a copy of has_consequent.""" 

23 return list(self.has_consequent) 

24 

25 def set_has_consequent(self, atom): 

26 """Add an atom to has_consequent.""" 

27 self.has_consequent.append(atom)