Giter Club home page Giter Club logo

terminus_store_prolog's Introduction

terminus-store prolog bindings

Build Status

Prolog bindings for the terminus-store Rust library.

Requirements

  • cargo
  • gcc
  • swi-prolog (with the include headers)

Installing

This library is downloadable through SWI-Prolog's package management system. In a swipl instance, run

pack_install(terminus_store_prolog).

Then you can use the library with

use_module(library(terminus_store)).

Compiling and running

If you need to compile manually, for example to test a change without reinstalling the pack, follow these instructions.

Use the wrapper script ./make rather than the Makefile directly. The wrapper script will set up swipl environment variables which the build needs.

Also, use the provided ./run_swipl script to start a test instance. This will ensure the foreign library will be located properly.

./make
./run_swipl

Running the tests

./make
./run_swipl -g run_tests -g halt

Examples

Creating a named graph and adding a triple

Create a new directory (testdir in this example), then do the following:

open_directory_store("testdir", Store),
open_write(Store, Builder),
create_named_graph(Store, "sometestdb", DB),
nb_add_triple(Builder, "Subject", "Predicate", value("Object")),
nb_commit(Builder, Layer),
nb_set_head(DB, Layer).

Add a triple to an existing named graph

open_directory_store("testdir", Store),
open_named_graph(Store, "sometestdb", DB),
open_write(DB, Builder),
nb_add_triple(Builder, "Subject2", "Predicate2", value("Object2")),
nb_commit(Builder, Layer),
nb_set_head(DB, Layer),

Query triples

open_directory_store("testdir", Store),
open_named_graph(Store, "sometestdb", DB),
head(DB, Layer),
triple(Layer, Subject, Predicate, Object).

Convert strings to ids and query by id

open_directory_store("testdir", Store),
open_named_graph(Store, "sometestdb", DB),
head(DB, Layer),
subject_id("Subject", S_Id),
id_triple(Layer, S_Id, P_Id, O_Id),
predicate_id(Predicate, P_Id),
object_id(Object, O_Id).

terminus_store_prolog's People

Contributors

matko avatar rrooij avatar gavinmendelgleason 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.