Documentation ¶
Overview ¶
Package vector implements word vector struct of word2vec.
Example (Dot) ¶
v := New(strings.Split("1.0 0.0 0.0 1.0 0.0 1.0 ", " ")) u := New(strings.Split(" 0.0 1.0 0.0 0.0 1.0 1.0", " ")) fmt.Println(v.dot(u))
Output: 1
Example (Norm) ¶
v := New(strings.Split("1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 ", " ")) fmt.Println(v.norm())
Output: 2.8284271247461903
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Expr ¶
Expr is an expression type.
Example ¶
v := New(strings.Split("1.0 0.0 0.0 1.0 0.0 1.0 ", " ")) u := New(strings.Split(" 0.0 1.0 0.0 0.0 1.0 1.0", " ")) s := "king" expr := NewExpr(v, u, s) fmt.Println(expr)
Output: king 0.333333%
type Vector ¶
type Vector []float64
Vector is a type which represents a word vector.
func New ¶
New returns a new vector with a given data.
Example ¶
data := strings.Split("1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 ", " ") v := New(data) fmt.Println(v)
Output: Vector(1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000) L2 Norm: 2.828427
Click to show internal directories.
Click to hide internal directories.