Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/macournoyer/utterance_parser

Extract intent and entities from natural language utterances
https://github.com/macournoyer/utterance_parser

extracts-intent nlp slot-filling

Last synced: 7 days ago
JSON representation

Extract intent and entities from natural language utterances

Awesome Lists containing this project

README

        

# UtteranceParser

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

It uses a [Naive Bayes classifier](https://en.wikipedia.org/wiki/Naive_Bayes_classifier) to determine intent and [Conditional random fields](https://en.wikipedia.org/wiki/Conditional_random_field) to extract entities.

For example, it can turn this:

> Remind me to pick up the kids in two hours

into ...

```ruby
[
# 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

```ruby
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 get stuff done " => "reminder",
"Remind me to buy milk " => "reminder",
"Remind me to pick up the kids " => "reminder",

"Play some jazz" => "play",
"Play some blues" => "play",
"Play some rap" => "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