fasttext

package module
v0.0.0-...-7f12196 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2018 License: NCSA Imports: 5 Imported by: 1

README

Go-FastText

Golang bindings to the fasttext library.

Usage

To perform a prediction on a model, use the following command

go run main.go prediction -m [model_path] [query]

For example

go run main.go predict -m ~/Downloads/ag_news.bin chicken

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analog

type Analog struct {
	Index       int     `json:"index"`
	Name        string  `json:"name"`
	Probability float32 `json:"probability"`
}

type Analogs

type Analogs []Analog

func (Analogs) Len

func (p Analogs) Len() int

Len is the number of elements in the collection.

func (Analogs) Less

func (p Analogs) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (Analogs) Sort

func (p Analogs) Sort()

func (Analogs) Swap

func (p Analogs) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type Model

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

A model object. Effectively a wrapper around the C fasttext handle

func Open

func Open(path string) *Model

Opens a model from a path and returns a model object

func (*Model) Analogy

func (handle *Model) Analogy(query string) (Analogs, error)

func (*Model) Close

func (handle *Model) Close() error

Closes a model handle

func (*Model) Predict

func (handle *Model) Predict(query string) (Predictions, error)

Performs model prediction

func (*Model) Wordvec

func (handle *Model) Wordvec(query string) (Vectors, error)

type Prediction

type Prediction struct {
	Index       int     `json:"index"`
	Probability float32 `json:"probability"`
	Label       string  `json:"label"`
}

type Predictions

type Predictions []Prediction

func (Predictions) Len

func (p Predictions) Len() int

Len is the number of elements in the collection.

func (Predictions) Less

func (p Predictions) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (Predictions) Sort

func (p Predictions) Sort()

func (Predictions) Swap

func (p Predictions) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type Vector

type Vector struct {
	Element float32 `json:"probability"`
}

type Vectors

type Vectors []Vector

func (Vectors) Len

func (p Vectors) Len() int

Len is the number of elements in the collection.

func (Vectors) Less

func (p Vectors) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (Vectors) Sort

func (p Vectors) Sort()

func (Vectors) Swap

func (p Vectors) Swap(i, j int)

Swap swaps the elements with indexes i and j.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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