diff --git a/src/py_arg/experiments/experiment_run_stability_algorithm.py b/src/py_arg/experiments/experiment_run_stability_algorithm.py index 09193f6..baa8138 100644 --- a/src/py_arg/experiments/experiment_run_stability_algorithm.py +++ b/src/py_arg/experiments/experiment_run_stability_algorithm.py @@ -52,8 +52,7 @@ def get_all_literals_stability(lp_file_name: str): if __name__ == "__main__": - get_literal_is_stable('generated_iat.lp', 'l0') - with os.scandir(r'C:\Users\Daphne\PycharmProjects\py_arg\py_arg\experiments\generated_data') as entries: + with os.scandir(r'generated_data') as entries: for entry in entries: filename = entry.name st, st2, et = get_all_literals_stability(filename) diff --git a/src/py_arg/import_export/incomplete_argumentation_theory_from_lp_file_reader.py b/src/py_arg/import_export/incomplete_argumentation_theory_from_lp_file_reader.py index b9cb83e..7997403 100644 --- a/src/py_arg/import_export/incomplete_argumentation_theory_from_lp_file_reader.py +++ b/src/py_arg/import_export/incomplete_argumentation_theory_from_lp_file_reader.py @@ -1,5 +1,3 @@ -import parse - from py_arg.aspic_classes.argumentation_system import ArgumentationSystem from py_arg.aspic_classes.defeasible_rule import DefeasibleRule from py_arg.aspic_classes.literal import Literal @@ -13,15 +11,29 @@ def __init__(self): @staticmethod def read_from_lp_file(file_path: str) -> IncompleteArgumentationTheory: - with open(file_path, 'r') as reader: - lines = reader.read() - positive_queryable_strs = [r[0] for r in parse.findall('queryable({})', lines)] - axiom_strs = [r[0] for r in parse.findall('axiom({})', lines)] - defeasible_rule_bodies = [(r[0], r[1]) for r in parse.findall('body({}, {})', lines)] - defeasible_rule_heads = [(r[0], r[1]) for r in parse.findall('head({}, {})', lines)] - contradiction_pairs = [(r[0], r[1]) for r in parse.findall('neg({}, {})', lines)] - preferred_pairs = [(r[0], r[1]) for r in parse.findall('preferred({}, {})', lines)] + positive_queryable_strs = [] + axiom_strs = [] + defeasible_rule_bodies = [] + defeasible_rule_heads = [] + contradiction_pairs = [] + preferred_pairs = [] + + reader = open(file_path, 'r') + for line in reader: + if line.startswith('queryable'): + positive_queryable_strs.append(line.split('(', 1)[1].split(')', 1)[0]) + if line.startswith('axiom'): + axiom_strs.append(line.split('(', 1)[1].split(')', 1)[0]) + if line.startswith('body'): + defeasible_rule_bodies.append((line.split('(', 1)[1].split(')', 1)[0]).split(', ', 1)) + if line.startswith('head'): + defeasible_rule_heads.append((line.split('(', 1)[1].split(')', 1)[0]).split(', ', 1)) + if line.startswith('neg'): + contradiction_pairs.append((line.split('(', 1)[1].split(')', 1)[0]).split(', ', 1)) + if line.startswith('preferred'): + preferred_pairs.append((line.split('(', 1)[1].split(')', 1)[0]).split(', ', 1)) + reader.close() all_positive_literals = set(positive_queryable_strs) for axiom in axiom_strs: