def addArgument(argArr): #split argument array into parts prompt = argArr[0] newArgument = argArr[1] parent = argArr[2] stance = argArr[3] #get sf doc sfStr = fm.getFile(prompt + ".json") sfJSON = json.loads(sfStr) sf.set_doc(sfJSON) #deal with parent argument being the debate prompt if (parent == "newReply"): parent = prompt #create argument if (stance == "agree"): sf.add_support(None, [newArgument], sf.get_atom_id(parent), None) if (stance == "disagree"): sf.add_conflict(None, newArgument, sf.get_atom_id(parent), None) #write updated sfDoc to file sfJSONex = sf.export_json() fm.createFile(sfJSONex) return None
def process_la(node, parent): conc = get_node_text(parent)[1] prem = [] ch = node.getchildren() for c in ch: if c.tag == "AU": prem.append(get_node_text(c)[1]) process_au(c) sadface.add_support(con_text=conc, prem_text=prem)
def process_ca(node, parent): """ The DTD allows only a single premise supporting a given conclusion within a single AU node. """ conc = get_node_text(parent)[1] prem = [] ch = node.getchildren() for c in ch: if c.tag == "AU": prem.append(get_node_text(c)[1]) process_au(c) sadface.add_support(con_text=conc, prem_text=prem)
def test_add_support(self): """ TESTS: add_support(con_text=None, prem_text=None, con_id=None, prem_id=None) """ sf.initialise() con1 = "You should treasure every moment" prem1 = [ "if you are going to die then you should treasure every moment", "You are going to die" ] arg1 = sf.add_support(con_text=con1, prem_text=prem1, con_id=None, prem_id=None) self.assertEqual(con1, arg1.get("conclusion").get("text")) prem1_atom = sf.get_atom(arg1.get("premises")[0]) self.assertEqual(prem1[0], prem1_atom.get("text")) prem2_atom = sf.get_atom(arg1.get("premises")[1]) self.assertEqual(prem1[1], prem2_atom.get("text"))
import json import sadface as sf sf.config.init("etc/test.cfg") sf.initialise() sf.set_title("very important") sf.add_notes("some nonsense about stuff...") sf.append_notes("yet more notes n stuff") sf.set_description("a cohesive description of this argument document") con1 = "You should treasure every moment" prem1 = ["if you are going to die then you should treasure every moment", "You are going to die"] arg1 = sf.add_argument(con_text=con1, prem_text=prem1, con_id=None, prem_id=None) t1 = sf.get_atom_id("You are going to die") prem2 = ["Every person is going to die", "You are a person"] arg2 = sf.add_support(con_text=None, prem_text=prem2, con_id=t1, prem_id=None) prem3 = "YOLO" arg3 = sf.add_conflict(arg_id=t1, conflict_text=prem3) print(sf.prettyprint()) dot = sf.export_dot()#trad=False) # Uncomment to use the brewer colourscheme with open('out.dot', 'w') as file: file.write(dot)