clmind

1.0.20 • Public • Published

Mind

CognitionLab's basic open-source learning AI core


Basic use

Install the module with: npm install clmind

// Load clmind
var clmind = require('clmind');
var mind = new clmind('Mind', 'User');

// Send input
mind.message("Hello there Mind!", function(response){
  // log to console
  console.log(
    '-> ' + response['user'] + ' - ' + response['msg']
  );
  console.log(
    '<- ' + response['mind'] + ' - ' + response['reply'];
  );
});

// Console output:
// $ -> User - Hello there Mind!
// $ <- Mind - Hello there User!

Documentation


new clmind (2 args)

botname

string name of the bot (default: MIND)

username

string name of the user (default: USER)

Warning: username and botname should be at least 3 characters long.

message (2 args)

msg

string the message to the mind

callback (1 arg)

function a callback function with one argument (optional)

returns object containing "user", "message", "mind", and "reply", either as return value, or first argument in the callback.

setUser (1 arg)

username

string new user's name

return the user's name or an Error.

setName (1 arg)

botname

string new bot's name

return string|Error the name of the bot, or an Error.

addEntry (2 args)

Add an entry into the mind's Concept Network

entry

string One or several sentences.

cns

conceptNetworkState see [ConceptNetworkState].

return Array|Error array of token nodes used in the entry.

generateResponse (no args)

Generate a response from the Concept Network and a network state.

return Object { response, nodes } The response is a string, and nodes is an array of nodes (see [linkNodesToLastSentence]).

linkNodesToLastSentence (1 arg)

Link nodes to the previous sentence node id (this is automatically set by addEntry, it is the node id of the first sentence of the entry).

Used with the nodes returned by addEntry.

nodes

Array Array of nodes ids.

injectConceptNetwork (1 arg)

Inject a new [ConceptNetwork] constructor. Useful when one wants to use specialized ConceptNetwork (e.g. FileConceptNetwork).

WARNING: reinitialize this.cn and this.cn[this.username].cns

NewConceptNetwok

ConceptNetwork derivated class of ConceptNetwork.


©CognitionLab LTD. 2017

'clmind' npm package free for non-commercial use.

Unmodified code portions ©François Parmentier.

cognitionlab.ltd

Dependents (0)

Package Sidebar

Install

npm i clmind

Weekly Downloads

1

Version

1.0.20

License

none

Last publish

Collaborators

  • erinsteph