GithubHelp home page GithubHelp logo

rule_matcher's Introduction

Rule Matcher

Rule Matcher Stored Procedures

This project requires Neo4j 3.2.x

Instructions

This project uses maven, to build a jar-file with the procedure in this project, simply package the project with maven:

mvn clean package

This will produce a jar-file, target/matcher-1.0-SNAPSHOT.jar, that can be copied to the plugin directory of your Neo4j instance.

cp target/rule-matcher-1.0-SNAPSHOT.jar neo4j-enterprise-3.2.3/plugins/.

Edit your Neo4j/conf/neo4j.conf file by adding this line:

dbms.security.procedures.unrestricted=com.maxdemarzi.*    

Restart your Neo4j Server.

Create the Schema by running this stored procedure:

CALL com.maxdemarzi.schema.generate

Create some test data:

CREATE (user1:User {username:'max'})
CREATE (user2:User {username:'jeff'})
CREATE (user3:User {username:'srikant'})
CREATE (user4:User {username:'stephen'})
CREATE (user5:User {username:'todd'})
CREATE (user6:User {username:'tyler'})

CREATE (a1:Attribute {id:'a1'})
CREATE (a2:Attribute {id:'a2'})
CREATE (a3:Attribute {id:'a3'})
CREATE (a4:Attribute {id:'a4'})
CREATE (a5:Attribute {id:'a5'})
CREATE (a6:Attribute {id:'a6'})

CREATE (user1)-[:HAS]->(a1)
CREATE (user1)-[:HAS]->(a2)

CREATE (user2)-[:HAS]->(a3)
CREATE (user2)-[:HAS]->(a4)

CREATE (user3)-[:HAS]->(a1)
CREATE (user3)-[:HAS]->(a3)

CREATE (user4)-[:HAS]->(a1)

CREATE (user5)-[:HAS]->(a5)

CREATE (user6)-[:HAS]->(a5)
CREATE (user6)-[:HAS]->(a6)

Create a rule:

CALL com.maxdemarzi.rules.create('Rule 1', '(a1 & a2) | (a3 & a4)')  # (a1 and a2) or (a3 and a4)
CALL com.maxdemarzi.rules.create('Rule 2', '(a1 & a2) | (a3 & !a4)') # (a1 and a2) or (a3 and NOT a4)

Match a user:

CALL com.maxdemarzi.match.user('max') yield node return node
CALL com.maxdemarzi.match.user('srikant') yield node return node

Match attributes:

CALL com.maxdemarzi.match.attributes(['a1','a2']) yield node return node
CALL com.maxdemarzi.match.attributes(['a1','a3']) yield node return node

See if attributes satisfy a rule:

CALL com.maxdemarzi.rules.satisfy('(a1 & a2) | (a3 & !a4)', ['a1', 'a4']) yield value return value

rule_matcher's People

Contributors

maxdemarzi avatar

Watchers

 avatar

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.