CleanCoach
CleanCoach is a clean language coaching bot written in ES6.
Node Usage
CleanCoach can be required just like any other node module.
const Coach = ;const clive = "Clive"; // you can give the coach a custom name herelet response = clive;console;
The primary ways of interacting with CleanCoach are:
const clive = "Clive"; // initialise a new coach with a nameclive; // get a clean response to a users input stringclive; // returns an object with many psychometrics about the session so forclive; // begins a new sessionclive; // resets the coach to a brand new state
getResponse(str, sel)
Takes an input string (str) and generates a response. getResponse is promise based so you can use .then and .catch etc.
getResponse can also take an optional 'sel' argument, which is another string. If the 'sel' string is present, the 'str' arugment will be used to formulate the reflective statement, and the 'sel' string will be used only to formulate the question. This can be useful for taking a user selected chunk of the 'str' string to use as focus for question creation.
The response is an object with the following structure:
data: {} // {Object} psychometric and session data about the input danger: false // {boolean} did the input contain a 'danger' word (e.g. suicide)? final: false // {boolean} did the input contain a closing word (e.g. goodbye)? reflection: 'and you want to get better at programming.' // {string} a reflective statement question: 'and what would you like to have happen?' // {string} a clean coaching question reply: 'and you want to get better at programming. and what would you like to have happen?' // {string} reflection + question;
getProfile()
Dumps all the session data into an object which looks like this:
"sessions":0 // total number of sessions "iterations":1 // total number of iterations in current sessions "sessionStartTime":"12:00:33" // current session start time in HH:mm:ss "sessionRunTime":4861 // current session run time in seconds "firstIssue":"moon" // the first item brought to the session "lastIssue":"moon" // the most recent item brought to the session "depthIssue":"moon" // the current 'depth' anchor item "json": "id":"0_1" // session_iteration "session":0 // session number "iteration":1 // iteration "time":"12:00:37" // timestamp "depth":1 // depth at this point "category":null // question category "question":null // unedited question "originalStr":"I want to go to the moon" // user's input "cleanedStr":"i want to go to the moon" // cleaned input "tokens":"i""want""to""go""to""the""moon" // array of tokens "stats": // !these stats are just for this one iteration! "age":922602 // age characteristics of the string "gender":609501 // gender characteristics of the string "past":-08187 // degree to which the string is past focused "present":-00608 // degree to which the string is present focused "future":-01899 // degree to which the string is future focused "optimism":490994586 // optimism = positive sentiment + future focus "affect":50639 // affect is degree of positive / negative sentiment... "intensity":25057 // ... intensity is the degree of exageration of that affect "POS_P":01926 // Seligman's PERMA theory "POS_E":05128 "POS_R":-00735 "POS_M":02261 "POS_A":01846 "NEG_P":01084 "NEG_E":03489 "NEG_R":01705 "NEG_M":01441 "NEG_A":02175 "pos": "nouns":"moon" "verbs":"want""go" "entities": "sentences":"i want to go to the moon" "adjectives": // unlike the stats above, these below are averages for the entire session "age":922602 "gender":609501 "past":-08187 "present":-00608 "future":-01899 "optimism":490994586 "affect":50639 "intensity":25057 "POS_P":01926 "POS_E":05128 "POS_R":-00735 "POS_M":02261 "POS_A":01846 "NEG_P":01084 "NEG_E":03489 "NEG_R":01705 "NEG_M":01441 "NEG_A":02175
newSession(false)
First look at the output of getProfile(). New session will bump the "sessions" number, and reset the following data to a blank state:
cliveinfo: "iterations":0 // total number of iterations in current sessions "sessionStartTime": null // current session start time "sessionRunTime": 0 // current session run time in seconds "firstIssue": // the first item brought to the session "lastIssue": // the most recent item brought to the session "depthIssue": // the current 'depth' anchor item
newSession will not reset any other profile information. To completely wipe all other profile information, use Coach.reset();
newSession takes one argument, a boolean. If the boolean is true, newSession() will also call getResponse() which will return a response object with a generic clean language question to get the new session started.
Options
CleanCoach has several options you can customise:
const clive = "Clive"; // initialise a new coach with a namecliveoptions = debug: false // print debug info to the console? maxDepth: 3 // maxmimum iterations to hold on to an item quoteUser: true // put quotes around the users input? removeSW: false // remove stop words when tokenising? trimFirstAnd: false // trim 'and' from reflective statemnt? trimSecondAnd: false // trim 'and' from question?;
CLI
npm install -g
will install a command-line interface called 'cleancoach' which can be used in your terminal.
Browser Usage
You can browserify the node module by doing:
npm run build
which will create a standalone coach.js file in the 'dist' folder.
In your main.js:
const coach = "Clive"; // You can give your coach a name here // configurable optionscoachoptionsdebug = false; // prints debug info to consolecoachoptionsmaxDepth = 3; // maximum iterations to hold on to a topiccoachoptionsquoteUser = true; // puts quote marks around user inputcoachoptionsremoveSW = false; // remove stop-words when tokenisingcoachoptionstrimFirstAnd = false; // remove "and" from the reflective statementcoachoptionstrimSecondAnd = false; // remove "and" from the response question // define a standard response in case of errorlet output = "Sorry, I didn't understand that. Try again." // Give the coach some input text (string) and get a responsecoach if responsereply // standard response output = responsereply; else if responsedanger // input contained a danger word (e.g. "suicide") // do some danger handling here (e.g. prompt with hotline number) output = responsereply; else if responsefinal // input contained a 'final' word (e.g. "goodbye") // do some final handling here (e.g. promt with save dialogue) coach; // resets the coach to new state console; coach; // resets the coach to new state return output
License
CleanCoach is made available under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3
(C) P. Hughes 2017-18. All rights reserved.
See LICENSE file for full license text