Utterance is the text entered by the user that can be used in your intents.

Sentiment I love you
Sentiment is positive!
Sentiment I hate you
Sentiment is negative :(
Sentiment Smell my cheese
Sentiment is neutral

Text and Scrubbed

When the user sends a message to GI the original text they entered and their text is scrubbed / cleaned using the Scrubber utility.

  • String is converted into lower case. HELLO -> hello
  • Contractions standardised. What’s -> what is
  • Grammar is removed. Great! -> great
  • Stop words are removed. The cat -> Cat
  • Octals are standardised. One, two, three -> 1, 2, 3

This is to help the system understand their intent and reduces the chances of calling the wrong intent.

//Users original text entered
request.utterance.original();

//Scrubbed text
request.utterance.text();

//Scrubbed text with stopwords removed
request.utterance.scrubbed('stopwords');
The cat, is in the hat!
Original: The cat, is in the hat!
Scrubbed: the cat is in the hat
Stop words: cat hat

Tagging words

The utterance is checked for various sentiments and intentions including if the users input is negative, positive a question and what type of question, such as “who” and “why”.

//If the input is a question
request.utterance.is('question');

//If the sentiment is positive
request.utterance.is('positive');

//If the sentiment is negative
request.utterance.is('negative');

Sentiment analysis

Sentiment analysis is to understand if the users input is positive, negative or neutral.

module.exports = class SentimentIntent extends Intent {

  setup() {
    this.train([
      new RegExp(/^sentiment/,'i')
    ]);
  }

  response(request) {
    let output = [];

    if(request.utterance.is('positive')) {
      output.push('Sentiment is positive!');
    }
    else if(request.utterance.is('negative')) {
      output.push('Sentiment is negative :(');
    }
    else {
      output.push('Sentiment is neutral');
    }

    return output;
  }

}

Sentiment I feel good
Sentiment is positive!
Sentiment I feel bad
Sentiment is negative :(
Sentiment I feel ok
Sentiment is neutral

Parts of speech

The speech tagger uses pos speech tagger. It’s still experimental and is not fully implemented yet.