0.03
No commit activity in last 3 years
No release in over 3 years
A trainable natural language parser that extracts intent and entities from utterances.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0

Runtime

~> 0.2
~> 0.1
~> 0.1
 Project Readme

UtteranceParser

A trainable natural language parser that extracts intent and entities from utterances.

It uses a Naive Bayes classifier to determine intent and Conditional random fields to extract entities.

For example, it can turn this:

Remind me to pick up the kids in two hours

into ...

[
  # intent
  "reminder",
  # entities
  {task: "pick up the kids", time: "in two hours"}
]

Installation

Add this line to your application's Gemfile:

gem 'utterance_parser'

And then execute:

$ bundle

Or install it yourself as:

$ gem install utterance_parser

Usage

parser = UtteranceParser.new

parser.train(
  # Utterance => intent
  "Hi" => "greeting",
  "Hello" => "greeting",

  "What time is it" => "time",
  "What's the weather outside" => "weather",

  # Mark entities using XML tags
  "Remind me to <task>get stuff done</task> <time>tomorrow</time>" => "reminder",
  "Remind me to <task>buy milk</task> <time>in one hour</time>" => "reminder",
  "Remind me to <task>pick up the kids</task> <time>in two hours</time>" => "reminder",

  "Play some <playlist>jazz</playlist>" => "play",
  "Play some <playlist>blues</playlist>" => "play",
  "Play some <playlist>rap</playlist>" => "play"
)

parser.parse "Hello there!"
# => ["greeting", {}]

parser.parse "Play some rock"
# => ["play", {playlist: "rock"}]

parser.parse "Remind me to buy stuff in three hours"
# => ["reminder", {task: "buy stuff", time: "in three hours"}]

Contributing

  1. Fork it ( https://github.com/macournoyer/utterance_parser/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request