Giter Site home page Giter Site logo

scientio's Introduction

Roboy ScientIO

About

Roboy ScientIO (from Lat. scientia - knowledge and Input/Output) - a Knowledge Graph Engine to organise and query complex data.

Dependencies

To use ScientIO, you will need to have one of it's supported back-ends installed. Currently, the only supported back-end is Neo4j, which may be run in a number of ways (if you don't have a remote instance available). We recommend simply running it through docker - like this:

docker run \
    --publish=7474:7474 --publish=7687:7687 \
    --volume=$HOME/neo4j/data:/data \
    --volume=$HOME/neo4j/logs:/logs \
    neo4j:3.0

Installation

Via PIP

The easiest way to install ScientIO is through pip:

pip install scientio

For developers

First, install dependencies:

pip install -r requirements.txt

Then, you may open the repository in any IDE, and mark the src folder as a sources root.

Basic ScientIO use-cases

Supplying an ontology description

The ontology description is a collection of named entity types, where each type may declare a specific set of properties and relationships like this:

# my_ontology.yml

!OType
entity: Alien    # The name of the ontology type
---
!OType
entity: Vulcan   # Declare a more specific Alien type
meta: [Alien]
properties:      # Allowed properties for every Vulcan
 - name
 - homeworld
 - ear_pointiness
---
!OType
entity: Human    # Declare a more specific Alien type
meta: [Alien]
properties:      # Allowed properties for every Human
 - name
 - homeworld
relationships: [captain_of]  # Allowed relationships for every Human

Creating some nodes

from scientio.ontology.ontology import Ontology
from scientio.session import Session
from scientio.ontology.node import Node

# Load the ontology from a yaml file
onto = Ontology(path_to_yaml="my_ontology.yml")

# Create a session (with default Neo4j backend)
sess = Session(
    ontology=onto,
    neo4j_address="bolt://localhost:7687",
    neo4j_username="neo4j",
    neo4j_password="test")

# Get human/vulcan types from ontology
human_type = onto.get_type("Human")
vulcan_type = onto.get_type("Vulcan")

# Create a transient human named "Kirk"
kirk = Node(metatype=human_type)
kirk.set_name("Kirk")

# Create a transient vulcan named "Spock"
spock = Node(metatype=vulcan_type)
spock.set_name("Spock")

# Persist kirk and spock
sess.create(kirk)
sess.create(spock)

Add a relationship between your nodes

from scientio.ontology.ontology import Ontology
from scientio.session import Session
from scientio.ontology.node import Node

# Load the ontology from a yaml file
onto = Ontology(path_to_yaml="my_ontology.yml")

# Create a session (with default Neo4j backend)
sess = Session(
    ontology=onto,
    neo4j_address="bolt://localhost:7687",
    neo4j_username="neo4j",
    neo4j_password="test")

# Get human/vulcan types from ontology
human_type = onto.get_type("Human")
vulcan_type = onto.get_type("Vulcan")

# Create query templates to get the actual kirk/spock
kirk = Node(metatype=human_type)
spock = Node(metatype=vulcan_type)

# Query Kirk and Spock from the database, using
# the query nodes we created previously. We're just
# gonna assume that the first human is Kirk, and the first
# vulcan is Spock.
kirk = sess.retrieve(request=kirk)[0]
spock = sess.retrieve(request=spock)[0]

# Add a relationship between Kirk and Spock
kirk.add_relationships({"captain_of": {spock.get_id()}})

# Make sure that the new relationship is persisted
sess.update(kirk)

scientio's People

Contributors

josephbirkner avatar l-laura avatar missxa avatar neginscode avatar toseban avatar waguramu 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.