From 1b02cf63a42e6e9dcc1e499efff7af04556ac3fd Mon Sep 17 00:00:00 2001 From: Daphne Odekerken Date: Mon, 22 Apr 2024 11:27:31 +0200 Subject: [PATCH] Fixed bug with dashes in literal names. --- .../read_argumentation_theory_functions.py | 43 +++++++++++-------- .../pages/22_visualise_aspic.py | 2 - 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/py_arg_visualisation/functions/import_functions/read_argumentation_theory_functions.py b/src/py_arg_visualisation/functions/import_functions/read_argumentation_theory_functions.py index 37aee02..e98884c 100644 --- a/src/py_arg_visualisation/functions/import_functions/read_argumentation_theory_functions.py +++ b/src/py_arg_visualisation/functions/import_functions/read_argumentation_theory_functions.py @@ -107,7 +107,10 @@ def read_argumentation_theory(axioms_str: str, ordinary_premises_str: str, # Derive the language: first obtain "absolute" literal strs from axioms and # rules def get_absolute(non_absolute_literal_str: str) -> str: - return non_absolute_literal_str.replace('~', '').replace('-', '') + while non_absolute_literal_str and non_absolute_literal_str[0] in '~-': + non_absolute_literal_str = non_absolute_literal_str[1:] + return non_absolute_literal_str + absolute_literal_strs = set() for literal in axioms + ordinary_premises: absolute_literal_strs.add(get_absolute(literal)) @@ -124,32 +127,38 @@ def get_absolute(non_absolute_literal_str: str) -> str: language = {} contraries_and_contradictories = {} for literal_str in absolute_literal_strs: - l_pos = Literal(literal_str) - l_naf = Literal('~' + literal_str) - l_neg = Literal('-' + literal_str) - language[l_pos.s1] = l_pos - language[l_naf.s1] = l_naf - language[l_neg.s1] = l_neg - - # Derive the contradiction function - contraries_and_contradictories[l_pos.s1] = {l_neg} - contraries_and_contradictories[l_naf.s1] = {l_pos} - contraries_and_contradictories[l_neg.s1] = {l_pos} + if literal_str != '': + l_pos = Literal(literal_str) + l_naf = Literal('~' + literal_str) + l_neg = Literal('-' + literal_str) + language[l_pos.s1] = l_pos + language[l_naf.s1] = l_naf + language[l_neg.s1] = l_neg + + # Derive the contradiction function + contraries_and_contradictories[l_pos.s1] = {l_neg} + contraries_and_contradictories[l_naf.s1] = {l_pos} + contraries_and_contradictories[l_neg.s1] = {l_pos} # Read axioms, ordinary premises, defeasible rules and strict rules, now in # the proper format axioms = [language[axiom_str] for axiom_str in axioms] ordinary_premises = [language[ordinary_premise_str] - for ordinary_premise_str in ordinary_premises] + for ordinary_premise_str in ordinary_premises + if ordinary_premise_str != ''] defeasible_rules = \ [DefeasibleRule(rule_id, {language[antecedent] - for antecedent in antecedents}, + for antecedent in antecedents + if antecedent != ''}, language[consequent]) - for rule_id, antecedents, consequent in defeasible_rules] + for rule_id, antecedents, consequent in defeasible_rules + if consequent != ''] strict_rules = [StrictRule(rule_id, {language[antecedent] - for antecedent in antecedents}, + for antecedent in antecedents + if antecedent != ''}, language[consequent]) - for rule_id, antecedents, consequent in strict_rules] + for rule_id, antecedents, consequent in strict_rules + if consequent != ''] # Read the ordinary premise preferences ordinary_premise_preference_strs = \ diff --git a/src/py_arg_visualisation/pages/22_visualise_aspic.py b/src/py_arg_visualisation/pages/22_visualise_aspic.py index 88a5653..2501925 100644 --- a/src/py_arg_visualisation/pages/22_visualise_aspic.py +++ b/src/py_arg_visualisation/pages/22_visualise_aspic.py @@ -8,8 +8,6 @@ from dash import ctx, html, callback, Input, Output, State, ALL, dcc from dash.exceptions import PreventUpdate -from py_arg.abstract_argumentation.import_export.argumentation_framework_from_json_reader import \ - ArgumentationFrameworkFromJsonReader from py_arg.aspic.classes.argumentation_system import ArgumentationSystem from py_arg.aspic.classes.argumentation_theory import ArgumentationTheory from py_arg.aspic.classes.instantiated_argument import InstantiatedArgument