File size: 1,211 Bytes
ba9863e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from .literal import Literal


class Argument:
    """
    Represents an argument in the argumentation framework.

    Attributes:
        argument_name (str): The name of the argument.
        claim (Literal): The claim/root literal of the argument.
        leaves (set[Literal]): The set of leaf literals supporting the claim.
    """

    def __init__(self, argument_name: str, claim: Literal, leaves: set[Literal]):
        self.argument_name: str = argument_name
        self.claim: Literal = claim
        self.leaves: set[Literal] = leaves

    def __eq__(self, other: object) -> bool:
        if not isinstance(other, Argument):
            return False
        return (
            self.claim == other.claim
            and self.leaves == other.leaves
        )

    def __str__(self) -> str:
        leaves_str = ','.join(str(literal) for literal in self.leaves)
        return f"[{self.argument_name}]={{{leaves_str}}} ⊢ {self.claim}"

    def __hash__(self) -> int:
        return hash((self.claim, frozenset(self.leaves)))

    def __repr__(self) -> str:
        leaves_str = ','.join(sorted(str(l) for l in self.leaves))
        return f"[{self.argument_name}]{{{leaves_str}}} ⊢ {self.claim}"