ner

package module
v0.0.0-...-036eccb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2015 License: MIT Imports: 4 Imported by: 0

README

NER

GoDoc Build Status

Named Entity Recognition for golang via the MITIE (MIT Information Extraction) library.

Installation
  • Install the MITIE library and header files. This does vary by platform. On a mac the easiest way would be brew install mitie. You'd have build from source on a linux system.
  • The go bindings will fail if the MITIE header files and dynamic library are not found.
  • go get github.com/sbl/ner
Usage

See _example/main.go for a simple usage example. Training files in your language of choice are required to be able to detect entities in text. See https://github.com/mit-nlp/MITIE#initial-setup for reference.

// In a nutshell
ext, err := ner.NewExtractor(path)
defer ext.Free()
if err != nil {
  return
}

tokens := ner.Tokenize(txt)

es, err := ext.Extract(tokens)
if err != nil {
  return
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCantOpen is returned by NewExtractor when a language model file can't
	// be loaded.
	ErrCantOpen = errors.New("Unable to open model file")
	// ErrMemory occurs when underlying C structs cannot be allocated.
	ErrMemory = errors.New("Could not allocate memory")
)

Functions

func Tokenize

func Tokenize(text string) []string

Tokenize returns a slice that contains a tokenized copy of the input text.

Types

type Entity

type Entity struct {
	Score     float64
	Tag       int
	TagString string
	Name      string
	Range     Range
}

Entity is a detected entity.

type Extractor

type Extractor struct {
	// contains filtered or unexported fields
}

Extractor detects entities based on a language model file.

func NewExtractor

func NewExtractor(path string) (*Extractor, error)

NewExtractor returns an Extractor given the path to a language model.

func (*Extractor) Extract

func (ext *Extractor) Extract(tokens []string) ([]Entity, error)

Extract runs the extractor and returns a slice of Entities found in the given tokens.

func (*Extractor) Free

func (ext *Extractor) Free()

Free frees the underlying used C memory.

func (*Extractor) Tags

func (ext *Extractor) Tags() []string

Tags returns a slice of Tags that are part of this language model. E.g. PERSON or LOCATION, etc…

type Range

type Range struct {
	Start int
	End   int
}

Range specifies the position of an Entity within a token slice.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL