Giter Site home page Giter Site logo

abaplusg's Introduction

Build Status

ABA+G

Note: Basic knowledge of argumentation theory is assumed throughout this documentation. If you are unfamiliar with this it's recommended that you read the material in the useful reading section before continuing.

Assumption Based Argumentation with goals and preferences (ABA+G) is a newly proposed formalism for structured argumentation.

This project provides an interface which implements reasoning using the ABA+G formalism. There are algorithms for calculating extensions of these frameworks under various semantics, a problem which is of interest in fields such as AI, Law and Medicine.

Install

First install the relevant dependecies by running the command make freeze && pip install -r requirements.txt. Then install the CLI tool by running pip install .

Mac / Windows

  • python3 -m piptools compile --output-file requirements.txt setup.py
  • pip3 install -r requirements.txt
  • pip3 install .

Some troubleshooting:

  • pip3 install --upgrade werkzeug in case of complaints about werkzeug

Use

A live version of the ABA+ app supporting ABA+G for reasoning with clinical guidelines is available as an API on http://aba-plus-g.herokuapp.com/. Currently the following endpoints are accessible:

  • /genereate_explanations is an endpoint which accepts a post request containing a valid DSS JSON object and returns the relevant extensions and accompanying explanations for which actions need to be taken in the treatment of patients.

Deployed

To send POST requests to the deployed ABA+G endpoint, from /requests run python post.py (modify URL as required). INPUT_FILE .json needs to be in /requests, the output .json will be appended with _arg and placed in /requests.

Stand-alone

Run python src/app.py from the main directory of the repository to run the flask server with ABA+G.

To send POST requests to the local ABA+G endpoint, from /requests run python post.py (modify URL as required). INPUT_FILE .json needs to be in /requests, the output .json will be appended with _arg and placed in /requests. You also need the requests library for this (pip3 install requests).

CLI

To get extensions of an ABA+ framework, python src/cli.py --file "FILENAME"


Users can specify the components of an ABA+G framework (i.e. Assumptions, Rules, Contraries, Preferences) in a file as follows: (Note that goals are as of now still unimplemented)

  • myAsm(a). specifies that a is an assumption;
  • contrary(a, x). specifies that x is the contrary of assumption a;
  • myRule(h, [b1]).** specifies that h <- b1 is a rule;
  • myPrefLT(b, a). specifies that assumption a is strictly preferred over assumption b;
  • myPrefLE(b, a). specifies that assumption a is strictly or equally preferred over assumption b;

Useful reading

The following papers provide a background on argumentation theory and this project.

Developing

The project comes with a set of commands you can use to run common operations for your stack:

  • make install: Installs run time dependencies.
  • make install-dev: Installs dev dependencies together with run time dependencies.
  • make freeze: Freezes dependencies from setup.py to requirements.txt (including transitive ones).
  • make lint: Runs static analysis.
  • make component: Runs component tests.
  • make coverage: Runs all tests collecting coverage.
  • make test: Runs lint and component.

Updating dependencies

Dependencies are managed from the setup.py file and then frozen in requirements.txt (including transitive dependencies) using make freeze (which uses pip-compile). If you want to change dependencies, you will have to do it in setup.py and then regenerate them using make freeze.

Imagine your setup.py looks like

install_requires = [  
 'pytest~=3.3.0',]  

if you want to update pytest to use version 3.4, you need to change it to

install_requires = [  
 'pytest~=3.4.0',]  

If you execute make freeze, it will regenerate the requirements.txt file with the new dependencies according to what the new version of pytest needs.

Deployment to Heroku

The Flask API available in src/app.py can easily be deployed to Heroku. Please refer to the Procfile in the root folder and the official Heroku documentation for more information on how to do this.

Contributing

If you would like to contribute to the project please follow these steps:

  • Clone the project locally.
  • Create a new feature branch.
  • Implement your feature while adhering to the development practices outlined above.
  • Once you are happy with your changes, make sure that the TravisCI checks are passing and create a pull request with a description of what you have changed.

Your pull request will be peer reviewed and merged into the master branch once ready.

abaplusg's People

Contributors

kcyras avatar aminkaramlou avatar

Stargazers

Ryan avatar

Watchers

James Cloos avatar  avatar

Forkers

susodominguez

abaplusg's Issues

Supports and attacks in ABA

for b in body:
# for every sentence b in the body
direct_supported_by[b] = direct_supported_by[b].union(direct_supported_by[head])
# add the direct supporters of non-assumption to the direct supporters of b, and similarly for the dicrect attackers, attackees and supportees
direct_attacked_by[b] = direct_attacked_by[b].union(direct_attacked_by[head])
direct_supports[b] = direct_supports[b].union(direct_supports[head])
direct_attacks[b] = direct_attacks[b].union(direct_attacks[head])

I don't think this works in ABA (when rules have more than one element in the bodies). Check text_supports_non-flat.pl counter-example.

rule antecedents as keys

direct_attacks[r.antecedent].add(a) # if r.antecedent were properly defined as a collection of sentences (for rules with more than one element in the body), then it would not generally be a sentence itself, and hence r.antecedent would not work as a key in direct_attacks

This would give key error if the language and rule antecedents were properly defined

Closures and attacks

ABAPlusG/src/aba_plus_g.py

Lines 160 to 175 in c016f44

def assumptions_directly_attacked_by(self, sentence):
'''
:param sentence: A string in self.language
:return: A set of strings which are assumptions directly attacked by sentence.
'''
return self.direct_attacks[sentence] # this should be sets of assumptions, in general, due to reverse attacks
def assumptions_which_directly_attack(self, assumption_set):
'''
:param assumption_set: A set of assumptions
:return: A set of strings in self. which are antecedents of a rule with sentence as its consequent.
'''
result = set()
for a in assumption_set:
result.update(self.direct_attacked_by[a])
return result

This can't really work in general ABA - the closure of a set of assumptions will not amount to the union of the closures of its assumptions.

Rule hash

ABAPlusG/src/aba_plus_g.py

Lines 250 to 253 in c016f44

def __hash__(self):
# I don't understand what turning the antecedent into a list and then a tuple is supposed to achieve
return (tuple(list(self.antecedent)),
self.consequent).__hash__()

I don't quite get this. At first I thought you turn the antecedent string into a list (which is weird because then it's just the list of all the symbols, but not really sentences) and then to make it hashable, into a tuple. But why?

Language

language.add(rule.antecedent) # this will result into a non-sensical language
# for s in rule.antecedent:
# language.add(s)

As it stands now, the language of a framework seems to be a collection of rule bodies as strings, so elements of the bodies of rules are not necessarily in the language, which seems wrong.

Labelling for general ABA closure

def add_closure_to_label_in(labelling, closure, framework):
for a in closure:
labelling[a] = Label.IN
for attacked in framework.assumptions_directly_attacked_by(a): # this can pick a set (of size at greater than 1) of assumptions attacked by a
for b in framework.get_inverse_closure(attacked): # whence attacked does not have an inverse closure
labelling[b] = Label.OUT

Also, generally, in ABA+, if an assumption attacks a set of assumptions, then not necessarily all the assumptions in the latter set will be out, and similarly regarding the closure, so this will probably not work for ABA+.

Rule antecedents

antecedent = match.group(2) # this makes the antecedent a string, rather than a tuple/list/set, so rules effectively cannot have multiple sentences in their bodies (antecedents)

This seem to require .split(", ") to get a list of sentences that comprise the body of the rule. But lists are not hashable, so maybe convert to tuples. But then if the body is empty or has a single elment, a tuple doesn't quite seem to work. Perhaps split into cases and work with strings and tuples, but then that needs to be checked every time...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.