CognitionLab's basic open-source learning AI core
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!
string name of the bot (default: MIND
)
string name of the user (default: USER
)
Warning: username and botname should be at least 3 characters long.
string the message to the mind
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.
string new user's name
return the user's name or an Error.
string new bot's name
return string|Error the name of the bot, or an Error.
Add an entry into the mind's Concept Network
string One or several sentences.
conceptNetworkState see [ConceptNetworkState].
return Array|Error array of token nodes used in the entry.
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]).
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.
Array Array of nodes ids.
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
ConceptNetwork derivated class of ConceptNetwork.
'clmind' npm package free for non-commercial use.
Unmodified code portions ©François Parmentier.