similarity

package
v0.0.0-...-22e7a19 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

README

Similarity

Calculate the cosine similarity between words.

Usage

Estimate the similarity between words

Usage:
  word-embedding sim -i FILENAME WORD [flags]

Examples:
word-embedding sim -i example/word_vectors.txt apple

Flags:
  -i, --input string   Input path of a file written words' vector with libsvm format (default "example/word_vectors.txt")
  -r, --rank int       Set number of the similar word list displayed (default 10)

Example

For instance, after running demo:

$ go run main.go sim -i example/word_vectors_sg.txt microsoft
    RANK |   WORD    |  COSINE
  +------+-----------+----------+
       1 | computers | 0.995368
       2 | ibm       | 0.993774
       3 | os        | 0.993721
       4 | machines  | 0.993713
       5 | operating | 0.993547
       6 | wikipedia | 0.993026
       7 | mpeg      | 0.992636
       8 | apple     | 0.992628
       9 | server    | 0.992574
      10 | unix      | 0.992385

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Estimator

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

Estimator stores the elements for cosine similarity.

func NewEstimator

func NewEstimator(target string, rank int) *Estimator

NewEstimator creates *SimilarityEstimator

func (*Estimator) Describe

func (e *Estimator) Describe() error

Describe shows the similar words list for target word.

func (*Estimator) Estimate

func (e *Estimator) Estimate(f io.ReadCloser) error

Estimate estimates the similarity for target word.

type Measure

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

Measure stores the word with cosine similarity value on the target.

type Measures

type Measures []Measure

Measures is the list of Sim.

func (Measures) Len

func (m Measures) Len() int

func (Measures) Less

func (m Measures) Less(i, j int) bool

func (Measures) Swap

func (m Measures) Swap(i, j int)

Jump to

Keyboard shortcuts

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