apradillap / mitie

Named-entity recognition for Ruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MITIE

MITIE - named-entity recognition and binary relation detection - for Ruby

  • Finds people, organizations, and locations in text
  • Detects relationships between entities, like PERSON was born in LOCATION

Build Status

Installation

Add this line to your application’s Gemfile:

gem 'mitie'

And download the pre-trained model for your language:

Getting Started

Load an NER model

model = Mitie::NER.new("ner_model.dat")

Create a document

doc = model.doc("Nat works at GitHub in San Francisco")

Get entities

doc.entities

This returns

[
  {text: "Nat",           tag: "PERSON",       score: 0.3112371212688382, offset: 0},
  {text: "GitHub",        tag: "ORGANIZATION", score: 0.5660115198329334, offset: 13},
  {text: "San Francisco", tag: "LOCATION",     score: 1.3890524313885309, offset: 23}
]

Get tokens

doc.tokens

Get tokens and their offset

doc.tokens_with_offset

Get all tags for a model

model.tags

Binary Relation Detection

Detect relationships betweens two entities, like:

  • PERSON was born in LOCATION
  • ORGANIZATION was founded in LOCATION
  • FILM was directed by PERSON

There are 21 detectors for English. You can find them in the binary_relations directory in the model download.

Load a detector

detector = Mitie::BinaryRelationDetector.new("rel_classifier_organization.organization.place_founded.svm")

And create a document

doc = model.doc("Shopify was founded in Ottawa")

Get relations

detector.relations(doc)

This returns

[{first: "Shopify", second: "Ottawa", score: 0.17649169745814464}]

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

To get started with development:

git clone https://github.com/ankane/mitie.git
cd mitie
bundle install
bundle exec rake vendor:all

export MITIE_MODELS_PATH=path/to/MITIE-models/english
bundle exec rake test

About

Named-entity recognition for Ruby

License:Boost Software License 1.0


Languages

Language:Ruby 97.7%Language:Shell 2.3%