Skip to content

Commit

Permalink
Structured ASPIC+ visualisation: toggle visualisation of contradictor…
Browse files Browse the repository at this point in the history
…ies.
  • Loading branch information
Daphne Odekerken committed Jan 5, 2024
1 parent 7e5699e commit ba629ca
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
from typing import List, Dict

from py_arg.aspic.classes.argumentation_theory import ArgumentationTheory
from py_arg_visualisation.functions.graph_data_functions.get_color \
import get_color
from py_arg_visualisation.functions.ordering_functions.\
get_ordering_by_specification import get_ordering_by_specification


def get_argumentation_theory_aspic_graph_data(
argumentation_theory: ArgumentationTheory, ordering_specification: str,
argumentation_theory: ArgumentationTheory,
selected_arguments: Dict[str, List[str]],
color_blind_mode: bool):
color_blind_mode: bool, show_contradictories: bool):
"""
Calculate the data needed for the graphical representation of the
argumentation theory and ordering
Expand All @@ -22,37 +18,42 @@ def get_argumentation_theory_aspic_graph_data(
:param selected_arguments: Arguments to be marked with a different
color (e.g. because they are in some extension)
:param color_blind_mode: Is the color-blind mode on?
:param show_contradictories: Do we display the contradictories?
"""
data_nodes = []
data_edges = []

used_literals = set()
for knowledge in argumentation_theory.knowledge_base:
used_literals.add(knowledge)
for contra in knowledge.contraries_and_contradictories:
used_literals.add(contra)
if show_contradictories:
for contra in knowledge.contraries_and_contradictories:
used_literals.add(contra)
for rule in argumentation_theory.argumentation_system.rules:
for antecedent in rule.antecedents:
used_literals.add(antecedent)
for contra in antecedent.contraries_and_contradictories:
used_literals.add(contra)
if show_contradictories:
for contra in antecedent.contraries_and_contradictories:
used_literals.add(contra)
used_literals.add(rule.consequent)
for contra in rule.consequent.contraries_and_contradictories:
used_literals.add(contra)
if show_contradictories:
for contra in rule.consequent.contraries_and_contradictories:
used_literals.add(contra)

# Contradictories
contra_counter = 0
for literal in used_literals:
for contrary in literal.contraries_and_contradictories:
if literal <= contrary:
contra_id = 'C' + str(contra_counter)
data_edges.append({'id': contra_id, 'arrows': '',
'from': literal.s1, 'to': contrary.s1,
'color': {'color': 'red'},
'smooth': {
'enabled': True,
'type': 'curvedCCW'}})
contra_counter += 1
if show_contradictories:
contra_counter = 0
for literal in used_literals:
for contrary in literal.contraries_and_contradictories:
if literal <= contrary:
contra_id = 'C' + str(contra_counter)
data_edges.append({'id': contra_id, 'arrows': '',
'from': literal.s1, 'to': contrary.s1,
'color': {'color': 'red'},
'smooth': {
'enabled': True,
'type': 'curvedCCW'}})
contra_counter += 1

# Create nodes for used literals
for literal in used_literals:
Expand Down
25 changes: 18 additions & 7 deletions src/py_arg_visualisation/pages/22_visualise_aspic.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
get_argumentation_framework_extensions
from py_arg_visualisation.functions.extensions_functions. \
get_acceptance_strategy import get_acceptance_strategy
from py_arg_visualisation.functions.graph_data_functions.get_aspic_graph_data import \
get_argumentation_theory_aspic_graph_data
from py_arg_visualisation.functions.graph_data_functions.get_aspic_graph_data \
import get_argumentation_theory_aspic_graph_data
from py_arg_visualisation.functions.graph_data_functions. \
get_at_graph_data import get_argumentation_theory_af_graph_data
from py_arg_visualisation.functions.import_functions. \
Expand Down Expand Up @@ -81,7 +81,15 @@ def get_aspic_layout(aspic_setting, structured_evaluation,
dcc.Tab(label='Structured visualisation', children=[
visdcc.Network(data={'nodes': [], 'edges': []},
id='22-aspic-graph',
options=aspic_options)]),
options=aspic_options),
dbc.Checklist(
options=[{'label': 'Show contradictories',
'value': 'show_contra'}],
value=['show_contra'],
inline=True, switch=True,
id='22-aspic-graph-show-contradictories'
),
]),
]))])])
return dbc.Row([left_column, right_column])

Expand Down Expand Up @@ -302,15 +310,16 @@ def generate_random_argumentation_theory(nr_of_clicks: int):
Input('ordering-choice', 'value'),
Input('ordering-link', 'value'),
Input('selected-argument-store-structured', 'data'),
State('color-blind-mode', 'on'),
Input('color-blind-mode', 'on'),
Input('22-aspic-graph-show-contradictories', 'value'),
prevent_initial_call=True
)
def create_argumentation_theory(
axioms_str: str, ordinary_premises_str: str, strict_rules_str: str,
defeasible_rules_str: str, ordinary_premise_preferences_str: str,
defeasible_rule_preferences_str: str, ordering_choice_value: str,
ordering_link_value: str, selected_arguments: Dict[str, List[str]],
color_blind_mode: bool):
color_blind_mode: bool, show_contradictories: bool):
# Read the ordering
ordering_specification = ordering_choice_value + '_' + ordering_link_value

Expand All @@ -328,9 +337,11 @@ def create_argumentation_theory(
af_graph_data = get_argumentation_theory_af_graph_data(
arg_theory, ordering_specification, selected_arguments,
color_blind_mode)

show_contra_bool = 'show_contra' in show_contradictories
aspic_graph_data = get_argumentation_theory_aspic_graph_data(
arg_theory, ordering_specification, selected_arguments,
color_blind_mode)
arg_theory, selected_arguments,
color_blind_mode, show_contra_bool)
return af_graph_data, aspic_graph_data


Expand Down

0 comments on commit ba629ca

Please sign in to comment.