Code Monkey home page Code Monkey logo

atomspace-rpc's Introduction

atomspace-rpc

This project uses grpc for executing pattern matching searches on a remote AtomSpace.

It also allows users to create multiple atomspaces and access them separately. Users can use a JSON config file to specify the id and the directory containing the atomese code to load. An example config looks like the following:

 [
   {
     "id": "asp1",
     "pathDir": "/path/to/atomese/code/"
   },
   {
     "id": "asp2",
     "pathDir": "/path/to/another/atomese/code"
   }   
 ]

You can use the above JSON to start the server:

$ atom_server --config /path/to/setting.json

By default the server runs at localhost:50051 . But you can that using the --host and --port arguments.

Building and Installation.

1. Requirements:

This project depends on the following libraries:

  • AtomSpace
  • Boost
    • On Debian you can use apt-get install libboost-dev
  • Protobuff
  • gRPC C++
    • See also here - https://grpc.io/docs/languages/cpp/quickstart/

    • Note: While building gRPC from the source, make sure to have the following cmake options. For more info check out this issue comment from the library maintainers.

      cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DgRPC_PROTOBUF_PROVIDER=package -DgRPC_ZLIB_PROVIDER=package -DgRPC_CARES_PROVIDER=package -DgRPC_SSL_PROVIDER=package -DCMAKE_BUILD_TYPE=Release ..

  • nlohmann_json
    • Since nlohmann json is a header only library just copy json.hpp to /usr/local/include/nlohmann directory. Create the nlohmann sub directory if it doesn't exist. Run the following command:

      $ mkdir -p /usr/local/include/nlohmann && \
      
      wget -O /usr/local/include/nlohmann/json.hpp https://github.com/nlohmann/json/releases/download/v3.9.1/json.hpp
      
  • agi-bio - this is OPTIONAL and will be required if you are working with bio related atomspace

Guile is also must be installed to use the scheme bindings

2. Building

$ cd atomspace_server
$ mkdir build && cd build
$ cmake ..
$ make 
$ make install

Usage

Once you have started the atom_server, run Guile REPL and execute the following commands:

A. To execute a pattern matching query

scheme@(guile-user)> (use-modules (opencog grpc))
scheme@(guile-user)> (exec-pattern "prod-atom" (Get  (Member (Gene "IGF1") (Variable "$pway"))))

In the above example, prod-atom is the id of the atomspace you want the pattern to be searched in.

B. Check if a node exists

scheme@(guile-user)> (check-node "prod-atom" 'Concept "A")

In the above example, we are checking if (Concept A) exists in remote atomspace prod-atom

C. Find Nodes with similar name

scheme@(guile-user)> (find-similar-node "prod-atom" 'Concept "ca")

The above query will return nodes that have ca in their name, such as (Concept "car") , (Concept "cat")..etc . The result is limited to return at most 10 atoms.

atomspace-rpc's People

Watchers

 avatar  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.