Coder Social home page Coder Social logo

lexpedite / blawx Goto Github PK

View Code? Open in Web Editor NEW
98.0 8.0 9.0 40.55 MB

A user-friendly web-based tool for Rules as Code.

License: MIT License

JavaScript 35.58% HTML 49.56% Python 14.07% Dockerfile 0.29% Shell 0.03% CSS 0.47%
rules-as-code logic-programming drag-and-drop blockly scasp

blawx's Introduction

Blawx

A user-friendly web-based tool for Rules as Code written by Jason Morris of Lexpedite Legal Technologies Ltd..

Blocks + law = Blawx

Blawx Front End Screenshot

Demonstration Video

Click on the thumbnail below for a recent video demonstration of how Blawx is used.

thumbnail

Overview

What is "Rules as Code"?

Rules as Code is the idea that if you write rules in a programming language at the same time you write them in a natural language, you end up with better rules, and you make it easier for people to automate implementations of those rules.

I believe:

  1. The best tools for doing knowledge representation of laws are declarative logic programming languages.
  2. Rules as Code requires tools that make it easy for non-programmers to do legal knowledge representation.
  3. Tools for Rules as Code must be accessible, and transparent, which means they need to be open source.

What is Blawx?

Blawx is an open source, user-friendly, web-based declarative logic knowledge representation tool designed specifically for encoding, testing and using rules.

It is implemented as a set of applications.

It provides:

  • a web server that stores your Blawx encodings and gives access to them and the reasoner over a RESTful API, based on Django
  • a visual development environment based on Google's Blockly to write, edit, and test your encodings
  • a reasoner based on SWI-Prolog and s(CASP) that will answer questions and explain the answers

Why Should I Use Blawx?

  • Open Source
  • Easy to Learn
  • Designed Specifically for Rules as Code
  • Publish Code as an API
  • Explainability
  • Hypothetical reasoning
  • User-friendly Scenario Explorer

Blawx is the only open source Rules as Code programming environment with a user-friendly scenario explorer, explanations for answers, and hypothetical reasoning.

How Can I Try It?

The easiest way to try Blawx is to go to dev.blawx.com. I try to keep a recent version running there for people to play with.

How do I Install It Myself?

If you would like to try running Blawx locally, install docker for your platform, and then run

docker run lexpedite/blawx

Blawx will then be available at (http://localhost:8000)[http://localhost:8000].

Check out INSTALL.md for more details.

How Can I Learn More?

Extensive documentation is available from inside the application by clicking "Help" in the left navigation menu. You can also view the documentation on the live demo site.

Is this software production ready?

No. Blawx is functional, but it is not production-quality software. It is intended for educational and experimental purposes.

Contributions

If you have issues or concerns with the package, please open an Issue in the GitHub Repository. Contributions to the code and documentation are welcome. Please contribute responsibly.

blawx's People

Contributors

asmith26 avatar calvinrodo avatar gauntlet173 avatar honeyqt avatar jeremykennedy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blawx's Issues

Generated Blocks Do Not Update When Their Source is Updated

If you declare an attribute as having a type, the next time you open the Known Attributes section of the toolbox you will receive a block with the new datatype. But any blocks already in the workspace are not updated with the new datatype.

This is problematic, because there is nothing stopping you from having the same attribute name in two different categories, which means that we probably can't solve this problem until the attributes are identified by their category.

Stop using Sleep() in reasoner.php

Reasoner.php is using sleep() commands in order to wait for Flora-2 to be finished processing commands. Whether that will work is dependent on the length of the code and the speed and availability of the processor on which Flora-2 is running.

We could make the requests asynchronous, or re-implement the reasoner in python with Pyxf, and poll whether Flora-2 is finished, or implement something similar in PHP.

Disallow multiple queries in a workspace

If a workspace contains multiple queries, it's not clear which of them the reasoner is supposed to run, and if more than one, in what order.

Temporarily, this could be resolved by setting the maximum number of query blocks to one.

Add Date/Time/Duration Data Types

Flora-2 supports Date, DateTime, Time, and Duration datatypes.

Would require datatype selectors for each, and value-setting blocks for each.

Overridden Answers are Still Returned

If you use an override block to say that one rule overrides another rule, and the override is triggered, both the original and the new result are reported as true.

This is likely because Flora-2 requires you to specify that answers "oppose" one another with \opposes statements that are not currently being generated.

Need to think about whether to add \opposes to the existing block or create a new block for it.

database error at blawx.com

I went to blawx.com to look for documentation but the site showed only the text "Error establishing a database connection".

Generate custom object declaration blocks based on declared categories

Right now, in order to say "Jason is a Person" you have to say "Person is a Category", "Jason is an Object", and "Jason is a Person." The middle step is pointless and slows you down.

When you create a category, it should generate the category selection block, but it should also generate an object declaration block for that category in the Objects drawer of the toolbox.

So you would say "person is a category", and then you would go to the objects drawer and find "_____ is a Person" as one of the options, and fill in "Jason".

The risk is that it will be used mutliple times with regard to the same symbol, which is risky because of the risk of typos, so we should also make it so that you can't have two object declarations with the same value for the name.

It may also make sense to get rid of the generic "Object" declaration entirely, and force people to choose a declared category whenever creating an object.

New Version of FLora-2

There is a new RC for Flora2.1, which includes useful date and time calculations. Need to confirm that the existing code works properly with the new RC in dev.

Reasoner Crashes if not provided data

In the dev branch, If there is no data parameter in the API call, the reasoner calls the json to flora-2 translator anyway, which crashes when it tries to open a empty or non-existent file.

Dockerfile: Add COPY commands to avoid having to clone blawx twice

The Dockerfile currently clones blawx inside the Docker container. Instead, we want to make it so users can first git clone https://github.com/Blawx/blawx.git and run docker build -t blawx . without the Dockerfile telling Docker to git clone blawx inside the container. Instead, the Dockerfile should use COPY to copy the cloned blawx repo into the container.

New Blockly Release

Just need to confirm that the system has not been broken by any of the changes in the new quarterly release of Blockly.

Report compilation warnings and errors in the user interface

Can be done by parsing output from Flora-2 in reasoner.py and including the results in the output JSON, then optionally displaying those results in the user interface. May want to create a configuration for whether you want to display warnings.

Dockerize the Development Environment

It would be great if we could dockerize the app for the purpose of fcilitating development and deployment.

Eventually, it should be structured with more than one container, to allow each to grow as required. But for now, if we could just get the single-machine installation process streamlined that would be a big win.

Python3 Not Included in Docker Container

Reasoner.php is expecting Python3 to be installed on the machine. API data features will be failing right now in docker installations as a result.

Probably just something that needs to be added to the dockerfile.

Add Constraints

I need a constraint block, and it needs to be able to accept comparators and equations over numbers only. That is going to require changing how comparators and non-identity operators are in the same block, right now. Might need to move the comparator operators to math, but check to see if they work on anything else.

Need to clean up installation process

Had a bunch of problems trying to install Flora-2 on Ubuntu in windows. Need to go back through the installation process step by step and make sure everything works.

Add Attribution Blocks with Cardinality

Cardinality for an attribute is how many values that attribute can have. One way to do this would be to create a set of 4 (or 5) different attribute declarations:

  • up to X
  • at least X
  • between X and Y
  • exactly X
  • optionally, any number, which is duplicative of zero or more.

Errors in reasoner.php under WSL2

The installation process has been updated to adjust for some of the changes caused by WSL2 and Ubuntu 20.04 running in Windows 10. However, the current installation process results in PHP errors being thrown from reasoner.php.

It is likely that the cause is a permission problem, or changes in where files are located on the new system.

Add package.json for npm dependency management

We should add a package.json to the repository for npm dependency management. This will help optimize Docker builds so npm install blockly xmlhttprequest can be replaced with npm install.

npm install will look at package.json to determine if any packages have been updated and only install/updated the dependencies if so.

I'm definitely not an expert with npm dependencies, so please feel free to correct me here if I'm wrong anywhere.

(self-assigning this @Gauntlet173!)

npm init reference: https://docs.npmjs.com/cli/init

Import Block Definitions from .json

Right now the block definitions are duplicated in the interface code in blawx_blocks.js and in decode.js.
Decode.js should just be importing blawx_blocks.js, or something.

npm warnings in docker container build process

npm WARN deprecated [email protected]: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported

Installation was in Gauntlet173/date branch, but likely exists in all of them

Boolean Data Values Inconsistent

Flora-2 uses \true as a boolean truth value, but Blawx is using true, which is an object named "true" in Flora-2. This is probably going to cause problems.

Add Rule Meta-Data

Facts and rules can have IDs, tags, defeasibility (strict, or defeasible), and arbitrary additional meta data. It would make sense to include 'link' and 'description' as basic meta-data elements for explainability.

The design challenge is to add these capabilities to both blocks without making them huge, and ugly.

In the best-case scenario there would be a mutator with the ability to specify which meta-data elements should be included.

As a first step, we might have two versions of the fact and rule blocks. One with meta-data, one without.

image

Remove Calculation Operator

For now, we are working on a naive implementation of the \is operator from Flora-2 to allow for mathematical calculations.

At some point, it would be preferrable to get rid of it by having math blocks de-nest, and turn into a chain of linked statements with randomly generated silent variable names.

For example, (4-2)+(7*8) would be interpreted as
?_x \is ?_a + ?_b, ?_a \is 4-2, ?_b \is 7*8, and then ?_x would be used in the place of the statement. Scoping the extra lines of code is going to be complicated, but it's feasible. So this is a wish-list item.

Add toType methods for datatypes

Currently, the value blocks allow you to type in things like dates and times, but you cannot use the value of other variables in order to generate them. We could allow that by including a toType method block for each of the types.

Comparison Operator May Be Missing Options

It currently does not have a unity operator, numerical equality operator, or the inequality operator from Flora-2, among others that may be less important. Numerical equality may not be important in the absence of different numerical types, I'm not sure.

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.