Code Monkey home page Code Monkey logo

pattern-index's Introduction

OpenCog

CircleCI

This repo is no longer maintained! Please use the following, instead:

Obsolete! As of 2021, the most interesting and actively maintained parts of this git repo have been split off into their own distinct git repos. What is left here is a mish-mash of unmatained stuff that is in the process of bit-rotting. Some unit tests fail. Some unit tests won't run. Some code won't compile. Perhaps there's some good stuff in here. Perhaps it can be brought back to life and used for something or other. However... for the most part, it is obsolete.


This git repository contains the "OpenCog Framework", which has served as a (scientific, technical) laboratory for researching, exploring and learning how to integrate AI algorithms and systems into humanoid robotic systems. Most of the activity within this particular repo has focused on integrating natural language chat, common-sense reasoning, assorted learning algorithms, and motor control of humanoid robots.

A stated goal of the OpenCog project is to develop artificial general intelligence (AGI) systems. This is all and well; however, what can be found here, in this particular repo, is very far from that. The code here really is ... a laboratory for integrating various types of AI systems. As such, it is a compilation of several decades of work by a large and varying collection of students, researchers, professors and software engineers. As a laboratory, it is filled with all sorts of devices in varying states of working order, from well-polished to mostly-broken.

See also:

  • ROCCA - Rational OpenCog Controlled Agent. This is a different assemblage of assorted OpenCog components, so that they operate within Minecraft, in the OpenAI Gym. The focus is on learning with the pattern miner, and reasoning with PLN.

Overview

Most of the basic components used in OpenCog are distributed across various git repos, (mostly) grouped under https://github.com/opencog

This git repository contains a crude natural language processing pipeline, several embodied chatbots, and some control/action-selection mechanisms. These include:

  • Ghost, a Chatscript-compatible chatbot with additional capabilities for accepting visual sensory input, and for controlling robot movements.

  • OpenPsi, a model of psychological states. Its currently a mashup of two unrelated ideas: a generic rule-class action-selection and planning system, and a model of human psychological states. An open to-do item is to untangle these two.

  • An assortment of natural language processing subsystems, including:

    • Natural language generation (for expressing thoughts as sentences).
    • Natural language input (for reading and hearing).
    • Relex2logic, converting natural language to logic expressions.
    • Assorted chatbots, some of which are embodied.
    • A Lojban tool.

Prerequisites

To build and run the system here, the packages listed below are required. Users of Ubuntu may use the dependency installer from the /opencog/octool repository. Docker containers with OpenCog preconfigured can be found in the opencog/docker repo.

cogutil

Common OpenCog C++ utilities. https://github.com/opencog/cogutil It uses exactly the same build procedure as this package. Be sure to sudo make install at the end.

atomspace

OpenCog Atomspace, a sophisticated (hyper-)graph database. https://github.com/opencog/atomspace It uses exactly the same build procedure as this package. Be sure to sudo make install at the end.

cogserver

OpenCog CogServer Network Server. https://github.com/opencog/cogserver It uses exactly the same build procedure as this package. Be sure to sudo make install at the end.

attention

OpenCog Attention Allocation subsystem. https://github.com/opencog/attention It uses exactly the same build procedure as this package. Be sure to sudo make install at the end.

URE

OpenCog Unified Rule Engine. https://github.com/opencog/ure Required for PLN It uses exactly the same build procedure as this package. Be sure to sudo make install at the end.

pln

OpenCog Probabilistic Logic Networks reasoning system. https://github.com/opencog/pln It uses exactly the same build procedure as this package. Be sure to sudo make install at the end.

spacetime

OpenCog Spacetime Server - locations of objects in space and time. https://github.com/opencog/spacetime It uses exactly the same build procedure as this package. Be sure to sudo make install at the end.

ros-behavior-scripting

Visual and auditory senses, robot motor control. https://github.com/opencog/ros-behavior-scripting It uses exactly the same build procedure as this package. Be sure to sudo make install at the end.

lg-atomese

Natural Language Parser for English, Russian, other languages. Required for natural language generation, and the chatbot. https://github.com/opencog/lg-atomese It uses exactly the same build procedure as this package. Be sure to sudo make install at the end.

Building OpenCog

Perform the following steps at the shell prompt:

    cd to project root dir
    mkdir build
    cd build
    cmake ..
    make

Libraries will be built into subdirectories within build, mirroring the structure of the source directory root.

Unit tests

To build and run the unit tests, from the ./build directory enter (after building opencog as above):

    make test

pattern-index's People

Contributors

ferrouswheel avatar kasimebrahim avatar linas avatar ngeiswei avatar roman-khimov avatar vsbogd avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pattern-index's Issues

Index does not return value for query with 3 EvaluationLink and 3 variables

Data:

(ImplicationLink
 (AndLink
  (EvaluationLink
   (PredicateNode "P")
   (ListLink
    (ConceptNode "A1")
    (ConceptNode "A2")))
  (EvaluationLink
   (PredicateNode "P")
   (ListLink
    (ConceptNode "A1")
    (ConceptNode "A3")))
  (EvaluationLink
   (PredicateNode "P")
   (ListLink
   (ConceptNode "A2")
   (ConceptNode "A3")))))

Query which can be placed into patternIndexQueryExample.cc file (see #1 and #2)

        std::string queryStr1 = "(ImplicationLink \
                                  (AndLink\
                                   (EvaluationLink\
                                     (PredicateNode \"P\")\
                                       (ListLink\
                                         (VariableNode \"A1\")\
                                         (VariableNode \"A2\")\
                                       )\
                                   )\
                                   (EvaluationLink\
                                     (PredicateNode \"P\")\
                                       (ListLink\
                                         (VariableNode \"A1\")\
                                         (VariableNode \"A3\")\
                                       )\
                                   )\
                                   (EvaluationLink\
                                     (PredicateNode \"P\")\
                                       (ListLink\
                                         (VariableNode \"A2\")\
                                         (VariableNode \"A3\")\
                                       )\
                                   )\
                                  )\
                                 )";

The result is

Query 1:
Result: (ListLink
) ; [9224779411738298928][1]

Unable to find Child Parent relation

Here is a simple example how to find son-parent relation using BindLink:

(use-modules (opencog) (opencog exec))

(Inheritance (Concept "John") (Concept "human"))
(Inheritance (Concept "John") (Concept "male"))

(Inheritance (Concept "Peter") (Concept "human"))
(Inheritance (Concept "Peter") (Concept "male"))

(Inheritance (Concept "Peter") (Concept "John"))

(define query-son
 (Bind
  (VariableList
   (Variable "$SON")
   (Variable "$PARENT"))
  (And
   (Inheritance (Variable "$PARENT") (Concept "human"))
   (Inheritance (Variable "$SON") (Concept "human"))
   (Inheritance (Variable "$SON") (Concept "male"))
   (Inheritance (Variable "$SON") (Variable "$PARENT")))
  (Variable "$SON")))

(display
 (cog-execute! query-son))

The same query with PatternIndex does not work for me.
scm file:

(Inheritance (Concept "John") (Concept "human"))
(Inheritance (Concept "John") (Concept "male"))

(Inheritance (Concept "Peter") (Concept "human"))
(Inheritance (Concept "Peter") (Concept "male"))

(Inheritance (Concept "Peter") (Concept "John"))

Conf file: ExampleConfig.conf

The scheme API seems to be broken #1 so I used the updated patternIndexQueryExample

#include <chrono>

#include <opencog/guile/SchemeEval.h>
#include <opencog/atomspace/AtomSpace.h>
#include <opencog/atoms/base/Handle.h>
#include <opencog/util/Config.h>

#include "PatternIndexAPI.h"

using namespace opencog;

int main(int argc, char *argv[]) {

    int exitValue = 0;

    if (argc != 3) {
        fprintf(stderr, "Usage: %s <SCM file> <config file>\n", argv[0]);
        exitValue = 1;
    } else {

        // Load configuration file
        config().load(argv[2]);

        // AtomSpace setup
        AtomSpace atomSpace;
        SchemeEval::init_scheme();
        SchemeEval::set_scheme_as(&atomSpace);
        SchemeEval *schemeEval = new SchemeEval(&atomSpace);

        // Create a new index given a SCM file
        Handle indexKey = patternindex().createIndex(argv[1]);

        // Optional setup of parameters which are relevant to
        // PatternIndexAPI::query()
        //
        // Sensible defaults are provided in
        // PatternIndexAPI::setDefaultProperties() but some tuning may be
        // required to adjust quality X memory usage X time performance.
        //
        // All parameters are described in
        // PatternIndexAPI::setDefaultProperties(). 
        patternindex().setProperty(indexKey,
                                   "PatternCountCacheEnabled",
                                   "true");
        patternindex().setProperty(indexKey,
                                   "DifferentAssignmentForDifferentVars",
                                   "true");
        patternindex().setProperty(indexKey,
                                   "PermutationsOfVarsConsideredEquivalent",
                                   "true");
        
        std::string queryStr1 = "(AndLink\
                                   (InheritanceLink\
                                     (VariableNode \"Parent\")\
                                     (ConceptNode \"human\")\
                                   )\
                                   (InheritanceLink\
                                     (VariableNode \"Son\")\
                                     (ConceptNode \"human\")\
                                   )\
                                   (InheritanceLink\
                                     (VariableNode \"Son\")\
                                     (ConceptNode \"male\")\
                                   )\
                                   (InheritanceLink\
                                     (VariableNode \"Son\")\
                                     (VariableNode \"Parent\")\
                                   )\
                                 )";
        Handle queryHandle = schemeEval->eval_h(queryStr1);
        Handle resultHandle = patternindex().query(indexKey, queryHandle);
        printf("Query 1:\n");
        printf("Result: %s", resultHandle->to_string().c_str());
    }

    return exitValue;
}

The result is:

Unknown type name: Inheritance
Unknown type name: Inheritance
Unknown type name: Inheritance
Unknown type name: Inheritance
Unknown type name: Inheritance
Query 1:
Result: (ListLink
) ; [9224779411738298928][1]

The expected result "Parent" is "John" and "Son" is "Peter" was not found.

pattern-index-query-example.scm sample does not work

Steps to reproduce

  • Build and install pattern-index project
  • go to opencog/pattern-index directory
  • run guile pattern-index-query-example.scm
    Output:
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /home/stellarspot/opencog/master/pattern-index/opencog/pattern-index/pattern-index-query-example.scm
;;; compiling /usr/share/guile/site/2.2/opencog/learning/pattern-index.scm
;;; WARNING: compilation of /usr/share/guile/site/2.2/opencog/learning/pattern-index.scm failed:
;;; In procedure mkstemp!: Permission denied
;;; WARNING: compilation of /home/stellarspot/opencog/master/pattern-index/opencog/pattern-index/pattern-index-query-example.scm failed:
;;; In procedure dynamic-link: file: "libpatternindex", message: "file not found"
Backtrace:
           4 (primitive-load "/home/stellarspot/opencog/master/patte…")
In ice-9/eval.scm:
   304:34  3 (_ #<directory (guile-user) 5643ab463140>)
   191:27  2 (_ #<directory (guile-user) 5643ab463140>)
   223:20  1 (proc #<directory (guile-user) 5643ab463140>)
In unknown file:
           0 (%resolve-variable (7 . pi-create-index) #<directory (g…>)

ERROR: In procedure %resolve-variable:
Unbound variable: pi-create-index

pattern-index doesn't compile using latest opencog/atomspace version

Build log:

The following components will be built:
-----------------------------------------------
   Pattern Index  - Pattern Index.
   Unit tests     - Unit tests.

The following components WILL NOT be built:
-----------------------------------------------
   Doxygen        - Code documentation.

-- Configuring done
-- Generating done
-- Build files have been written to: /ws/patternindex/build
Scanning dependencies of target patternindex
[  6%] Building CXX object opencog/pattern-index/CMakeFiles/patternindex.dir/PatternIndexAPI.cc.o
/ws/patternindex/opencog/pattern-index/PatternIndexAPI.cc: In member function ‘opencog::Handle opencog::PatternIndexAPI::query(opencog::Handle, opencog::Handle)’:
/ws/patternindex/opencog/pattern-index/PatternIndexAPI.cc:496:75: error: cannot bind rvalue reference of type ‘opencog::HandleSeq&& {aka std::vector<opencog::Handle>&&}’ to lvalue of type ‘const std::vector<opencog::Handle>’
         Handle satisfyingSubgraph = atomSpace->add_link(LIST_LINK, result.first);
                                                                    ~~~~~~~^~~~~
In file included from /usr/local/include/opencog/guile/SchemeSmob.h:28:0,
                 from /ws/patternindex/opencog/pattern-index/PatternIndexAPI.h:33,
                 from /ws/patternindex/opencog/pattern-index/PatternIndexAPI.cc:1:
/usr/local/include/opencog/atomspace/AtomSpace.h:188:12: note:   initializing argument 2 of ‘opencog::Handle opencog::AtomSpace::add_link(opencog::Type, opencog::HandleSeq&&)’
     Handle add_link(Type, HandleSeq&&);
            ^~~~~~~~
/ws/patternindex/opencog/pattern-index/PatternIndexAPI.cc:497:75: error: cannot bind rvalue reference of type ‘opencog::HandleSeq&& {aka std::vector<opencog::Handle>&&}’ to lvalue of type ‘opencog::HandleSeq {aka std::vector<opencog::Handle>}’
         Handle varMapping = atomSpace->add_link(LIST_LINK, variableMapping);
                                                                           ^
In file included from /usr/local/include/opencog/guile/SchemeSmob.h:28:0,
                 from /ws/patternindex/opencog/pattern-index/PatternIndexAPI.h:33,
                 from /ws/patternindex/opencog/pattern-index/PatternIndexAPI.cc:1:
/usr/local/include/opencog/atomspace/AtomSpace.h:188:12: note:   initializing argument 2 of ‘opencog::Handle opencog::AtomSpace::add_link(opencog::Type, opencog::HandleSeq&&)’
     Handle add_link(Type, HandleSeq&&);
            ^~~~~~~~
/ws/patternindex/opencog/pattern-index/PatternIndexAPI.cc:504:55: error: cannot bind rvalue reference of type ‘opencog::HandleSeq&& {aka std::vector<opencog::Handle>&&}’ to lvalue of type ‘opencog::HandleSeq {aka std::vector<opencog::Handle>}’
     return atomSpace->add_link(LIST_LINK, resultVector);
                                                       ^
In file included from /usr/local/include/opencog/guile/SchemeSmob.h:28:0,
                 from /ws/patternindex/opencog/pattern-index/PatternIndexAPI.h:33,
                 from /ws/patternindex/opencog/pattern-index/PatternIndexAPI.cc:1:
/usr/local/include/opencog/atomspace/AtomSpace.h:188:12: note:   initializing argument 2 of ‘opencog::Handle opencog::AtomSpace::add_link(opencog::Type, opencog::HandleSeq&&)’
     Handle add_link(Type, HandleSeq&&);
            ^~~~~~~~
/ws/patternindex/opencog/pattern-index/PatternIndexAPI.cc: In member function ‘opencog::Handle opencog::PatternIndexAPI::minePatterns(opencog::Handle)’:
/ws/patternindex/opencog/pattern-index/PatternIndexAPI.cc:534:55: error: cannot bind rvalue reference of type ‘opencog::HandleSeq&& {aka std::vector<opencog::Handle>&&}’ to lvalue of type ‘opencog::HandleSeq {aka std::vector<opencog::Handle>}’
     return atomSpace->add_link(LIST_LINK, resultVector);
                                                       ^
In file included from /usr/local/include/opencog/guile/SchemeSmob.h:28:0,
                 from /ws/patternindex/opencog/pattern-index/PatternIndexAPI.h:33,
                 from /ws/patternindex/opencog/pattern-index/PatternIndexAPI.cc:1:
/usr/local/include/opencog/atomspace/AtomSpace.h:188:12: note:   initializing argument 2 of ‘opencog::Handle opencog::AtomSpace::add_link(opencog::Type, opencog::HandleSeq&&)’
     Handle add_link(Type, HandleSeq&&);
            ^~~~~~~~
opencog/pattern-index/CMakeFiles/patternindex.dir/build.make:82: recipe for target 'opencog/pattern-index/CMakeFiles/patternindex.dir/PatternIndexAPI.cc.o' failed
make[2]: *** [opencog/pattern-index/CMakeFiles/patternindex.dir/PatternIndexAPI.cc.o] Error 1
CMakeFiles/Makefile2:314: recipe for target 'opencog/pattern-index/CMakeFiles/patternindex.dir/all' failed
make[1]: *** [opencog/pattern-index/CMakeFiles/patternindex.dir/all] Error 2
Makefile:171: recipe for target 'all' failed
make: *** [all] Error 2

Exited with code exit status 2

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.