Skip to content

Commit

Permalink
Merge pull request opencog#23 from ngeiswei/merge-opencog-to-singnet
Browse files Browse the repository at this point in the history
Merge opencog -> singnet
  • Loading branch information
ngeiswei authored Jul 9, 2020
2 parents b5440d3 + 4d176c8 commit 2aa9bf5
Show file tree
Hide file tree
Showing 9 changed files with 311 additions and 139 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2.0
jobs:
ure:
docker:
- image: singularitynet/opencog-deps
- image: $CIRCLE_PROJECT_USERNAME/opencog-deps
user: root
environment:
CCACHE_DIR: /ws/ccache
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:

miner:
docker:
- image: singularitynet/opencog-deps
- image: $CIRCLE_PROJECT_USERNAME/opencog-deps
user: root
environment:
CCACHE_DIR: /ws/ccache
Expand Down Expand Up @@ -134,7 +134,7 @@ jobs:

pln:
docker:
- image: opencog/opencog-deps
- image: $CIRCLE_PROJECT_USERNAME/opencog-deps
user: root
environment:
CCACHE_DIR: /ws/ccache
Expand Down Expand Up @@ -186,7 +186,7 @@ jobs:

opencog:
docker:
- image: singularitynet/opencog-deps
- image: $CIRCLE_PROJECT_USERNAME/opencog-deps
user: root
environment:
CCACHE_DIR: /ws/ccache
Expand Down Expand Up @@ -241,7 +241,7 @@ jobs:

package: #Place holder
docker:
- image: singularitynet/opencog-deps
- image: $CIRCLE_PROJECT_USERNAME/opencog-deps
user: root
working_directory: /ws/ure
steps:
Expand Down
85 changes: 5 additions & 80 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ ENDIF (ATOMSPACE_FOUND)
# add the 'cmake' directory from cogutil to search path
list(APPEND CMAKE_MODULE_PATH ${COGUTIL_DATA_DIR}/cmake)
include(OpenCogGccOptions)
include(OpenCogLibOptions)
include(OpenCogInstallOptions)
include(Summary)

# ----------------------------------------------------------
Expand All @@ -104,7 +106,7 @@ SET(Boost_USE_MULTITHREADED ON)
SET(MIN_BOOST 1.46)

# Required boost packages
FIND_PACKAGE(Boost ${MIN_BOOST} REQUIRED COMPONENTS date_time filesystem serialization system thread)
FIND_PACKAGE(Boost ${MIN_BOOST} REQUIRED)

IF(Boost_FOUND)
SET(Boost_FOUND_SAVE 1)
Expand All @@ -130,31 +132,9 @@ ELSE (CXXTEST_FOUND)
ENDIF (CXXTEST_FOUND)

# ----------------------------------------------------------
# This is required for Guile
FIND_LIBRARY(GMP_LIBRARY gmp)
FIND_PATH(GMP_INCLUDE_DIR gmp.h)

# Gnu Guile scheme interpreter. Mandatory
# Version 2.2.2 is needed for mrs io ports, compilation, atomics, nlp
FIND_PACKAGE(Guile 2.2.2)
IF (GUILE_FOUND AND GMP_LIBRARY AND GMP_INCLUDE_DIR)
ADD_DEFINITIONS(-DHAVE_GUILE)
SET(HAVE_GUILE 1)
INCLUDE_DIRECTORIES(${GUILE_INCLUDE_DIR})
ELSE (GUILE_FOUND AND GMP_LIBRARY AND GMP_INCLUDE_DIR)
SET(GUILE_DIR_MESSAGE "Guile was not found; the scheme shell will not be built.\nTo over-ride, make sure GUILE_LIBRARIES and GUILE_INCLUDE_DIRS are set.")
MESSAGE(FATAL_ERROR "${GUILE_DIR_MESSAGE}")
ENDIF (GUILE_FOUND AND GMP_LIBRARY AND GMP_INCLUDE_DIR)


# ----------------------------------------------------------
# secure_getenv
INCLUDE(CheckSymbolExists)
CHECK_SYMBOL_EXISTS(secure_getenv "stdlib.h" HAVE_SECURE_GETENV)
IF (HAVE_SECURE_GETENV)
ADD_DEFINITIONS(-DHAVE_SECURE_GETENV)
ENDIF (HAVE_SECURE_GETENV)
# This is required for Guile, Python

include(OpenCogFindGuile)
include(OpenCogFindPython)

# ----------------------------------------------------------
Expand Down Expand Up @@ -202,54 +182,6 @@ INCLUDE("${ATOMSPACE_DATA_DIR}/cmake/OpenCogMacros.cmake")
INCLUDE("${ATOMSPACE_DATA_DIR}/cmake/OpenCogGuile.cmake")
INCLUDE("${ATOMSPACE_DATA_DIR}/cmake/OpenCogCython.cmake")

# -------------------------------------------------
# Library configuration

# Small hack to handle unixes that use "/usr/lib64" instead of
# "/usr/lib" as the default lib path on 64 bit archs.
#
IF (NOT DEFINED LIB_DIR_SUFFIX)
EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} -print-search-dirs OUTPUT_VARIABLE PRINT_SEARCH_DIRS_OUTPUT)
STRING(REGEX MATCH "\r?\nlibraries:.*\r?\n" COMPILER_LIB_SEARCH_DIRS ${PRINT_SEARCH_DIRS_OUTPUT})
IF (NOT ${COMPILER_LIB_SEARCH_DIRS} STREQUAL "")
STRING(REGEX MATCH "/lib64/:|/lib64:|/lib64\n" HAS_LIB64 ${COMPILER_LIB_SEARCH_DIRS})
IF (NOT ${HAS_LIB64} STREQUAL "")
SET(LIB_DIR_SUFFIX "64")
ENDIF (NOT ${HAS_LIB64} STREQUAL "")
ENDIF (NOT ${COMPILER_LIB_SEARCH_DIRS} STREQUAL "")
ENDIF (NOT DEFINED LIB_DIR_SUFFIX)

# RPATH handling (see https://cmake.org/Wiki/CMake_RPATH_handling)
# Note: RPATH only supported under Linux!
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH
"${CMAKE_INSTALL_PREFIX}/lib/opencog"
"${PYTHON_DEST}")

SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# -------------------------------------------------
# Install configuration

# Only list install files that have actually changed.
SET(CMAKE_INSTALL_MESSAGE "LAZY")

# Set confdir and datadir.
IF (NOT DEFINED CONFDIR)
SET (CONFDIR "${CMAKE_INSTALL_PREFIX}/etc")
ENDIF (NOT DEFINED CONFDIR)

IF (NOT DEFINED DATADIR)
SET (DATADIR "${CMAKE_INSTALL_PREFIX}/share/opencog")
ENDIF (NOT DEFINED DATADIR)

ADD_DEFINITIONS(-DCONFDIR="${CONFDIR}")
ADD_DEFINITIONS(-DDATADIR="${DATADIR}")

# (re?)define MAN_INSTALL_DIR
SET (MAN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/man")

# ==========================================================
# Decide what to build, based on the packages found.

Expand Down Expand Up @@ -360,13 +292,6 @@ SET(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local")
SET(DEPENDENCY_LIST
"guile-2.2-dev (>= 2.2.2)"
"python3-dev (>= 3.6.7)"
"libboost-date-time-dev (>= ${MIN_BOOST})"
"libboost-filesystem-dev (>= ${MIN_BOOST})"
"libboost-program-options-dev (>= ${MIN_BOOST})"
"libboost-regex-dev (>= ${MIN_BOOST})"
"libboost-serialization-dev (>= ${MIN_BOOST})"
"libboost-thread-dev (>= ${MIN_BOOST})"
"libboost-system-dev (>= ${MIN_BOOST})"
"libboost-random-dev (>= ${MIN_BOOST})"
"libstdc++6 (>= 4.7)"
"libcogutil-dev (>= 2.0.2)"
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Unified Rule Engine

[![CircleCI](https://circleci.com/gh/opencog/ure.svg?style=svg)](https://circleci.com/gh/opencog/ure)
opencog | singnet
------- | -------
[![CircleCI](https://circleci.com/gh/opencog/ure.svg?style=svg)](https://circleci.com/gh/opencog/ure) | [![CircleCI](https://circleci.com/gh/singnet/ure.svg?style=svg)](https://circleci.com/gh/singnet/ure)

The Unified Rule Engine, URE for short, is a term rewriting engine for
OpenCog. It can be used to implement any logic. As of today it is used
Expand Down
22 changes: 22 additions & 0 deletions opencog/scm/opencog/ure/ure-utils.scm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
;; -- ure-rm-all-rules -- Remove all rules from the given rbs
;; -- ure-rules -- List all rules of a given rule base
;; -- ure-weighted-rules -- List all weighted rules of a given rule base
;; -- ure-search-rules -- Retrieve all potential rules
;; -- ure-set-num-parameter -- Set a numeric parameter of an rbs
;; -- ure-set-fuzzy-bool-parameter -- Set a fuzzy boolean parameter of an rbs
;; -- ure-set-attention-allocation -- Set the URE:attention-allocation parameter
Expand Down Expand Up @@ -79,6 +80,7 @@
(use-modules (opencog logger))
(use-modules (srfi srfi-1))
(use-modules (ice-9 receive))
(use-modules (ice-9 optargs))

(define* (cog-fc rbs source
#:key
Expand Down Expand Up @@ -537,6 +539,26 @@
(cog-set-atomspace! current-as)
clean-weighted-rules))

(define*-public (ure-search-rules #:optional (as (cog-atomspace)))
"
Retrieve all potential rules in the given or default atomspace.
https://github.com/singnet/ure/issues/16
"
(define current-as (cog-atomspace))

(define (filter-pot-rules DL-ATOMS-LIST)
(let* ((has-bind (lambda (x) (eq? 'BindLink (cog-type (cog-outgoing-atom x 1))))))
(filter has-bind DL-ATOMS-LIST)))

(cog-set-atomspace! as)

(let* ((dl-atoms-list (cog-get-atoms 'DefineLink))
(filtered-list (filter-pot-rules dl-atoms-list))
(rules-list (map (lambda (x) (cog-outgoing-atom x 0)) filtered-list)))

(cog-set-atomspace! current-as)
rules-list))

(define (ure-set-num-parameter rbs name value)
"
Set numerical parameters. Given an rbs, a parameter name and its
Expand Down
Loading

0 comments on commit 2aa9bf5

Please sign in to comment.