Beispiel #1
0
    def setUp(self):
        self.uri = '/api/v1.1/'
        self.headers = {'content-type': 'application/json'}

        # Populate a test AtomSpace
        self.atomspace = AtomSpace()
        self.animal = self.atomspace.add_node(
            types.ConceptNode, 'animal', TruthValue(.1, 0.0011860914528369904))
        self.bird = self.atomspace.add_node(
            types.ConceptNode, 'bird', TruthValue(.01, 0.0011237357975915074))
        self.swan = self.atomspace.add_node(
            types.ConceptNode, 'swan', TruthValue(.001, 0.0011237357975915074))
        self.frog = self.atomspace.add_node(
            types.ConceptNode, 'frog', TruthValue(.001, 0.7142857313156128))
        self.swan_bird = self.atomspace.add_link(
            types.InheritanceLink, [self.swan, self.bird],
            TruthValue(1, 0.0011237357975915074))
        self.bird_animal = self.atomspace.add_link(
            types.InheritanceLink, [self.bird, self.animal],
            TruthValue(1, 0.0011237357975915074))
        self.bird.sti = 9
        self.swan.sti = 9

        self.api = RESTAPI(self.atomspace)
        self.client = self.api.test()
Beispiel #2
0
    def setUp(self):
        self.uri = '/api/v1.1/'
        self.headers = {'content-type': 'application/json'}

        # Populate a test AtomSpace
        self.atomspace = AtomSpace()
        self.animal = self.atomspace.add_node(types.ConceptNode, 'animal',
                                              TruthValue(.1, .95))
        self.bird = self.atomspace.add_node(types.ConceptNode, 'bird',
                                            TruthValue(.01, .9))
        self.swan = self.atomspace.add_node(types.ConceptNode, 'swan',
                                            TruthValue(.001, .9))
        self.frog = self.atomspace.add_node(types.ConceptNode, 'frog',
                                            TruthValue(.001, 2000))
        self.swan_bird = self.atomspace.add_link(types.InheritanceLink,
                                                 [self.swan, self.bird],
                                                 TruthValue(1, .9))
        self.bird_animal = self.atomspace.add_link(types.InheritanceLink,
                                                   [self.bird, self.animal],
                                                   TruthValue(1, .9))
        self.bird.av = {'sti': 9}
        self.swan.av = {'sti': 9}

        self.api = RESTAPI(self.atomspace)
        self.client = self.api.test()
Beispiel #3
0
    def invoke(self):
        self.api = RESTAPI(self.atomspace)

        # OK, so if the remote end closes the pipe, we get a SIGPIPE
        # error, and the server dies.  So just restart the server in
        # that situation. See bug opencog/ros-behavior-scripting/issues/108
        try_again = True
        while try_again:
            try_again = False
            try:
                self.api.run(host=IP_ADDRESS, port=PORT)
            except socket.error, e:
                try_again = True
Beispiel #4
0
    def run(self):

        atomspace = AtomSpace()
        scheme_clear=\
         """
			(clear)
			"""
        scheme_code=\
          """
				(load-scm-from-file "/home/mahlet/webCodes/moses_result.scm")
				"""
        scheme_eval(atomspace, scheme_clear)
        scheme_eval(atomspace, scheme_code)

        #start the REST API
        IP_ADDRESS = '0.0.0.0'
        PORT = 5000
        api = RESTAPI(atomspace)
        api.run(host=IP_ADDRESS, port=PORT)
Beispiel #5
0
 def invoke(self):
     self.api = RESTAPI(self.atomspace)
     self.api.run(host=IP_ADDRESS, port=PORT)
from web.api.apimain import RESTAPI
from opencog.atomspace import AtomSpace, types
from opencog.utilities import initialize_opencog
from opencog.type_constructors import *

# Endpoint configuration
# To allow public access, set to 0.0.0.0; for local access, set to 127.0.0.1
IP_ADDRESS = '0.0.0.0'
PORT = 5000

atomspace = AtomSpace()
initialize_opencog(atomspace)

Link(ConceptNode("Test Concept"), ConceptNode("another one"))

api = RESTAPI(atomspace)
api.run(host=IP_ADDRESS, port=PORT)