bayes

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bayes

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

Bayes bayes文本分类

func New

func New() *Bayes

New 新建Bayes

func NewFromModel

func NewFromModel(model Model) *Bayes

NewFromModel 从model新建Bayes

func NewFromReader

func NewFromReader(r io.Reader) (*Bayes, error)

NewFromReader 从io.Reader创建Bayes

func (*Bayes) AddWords

func (b *Bayes) AddWords(cat string, words map[string]float64)

AddWords 添加keywords

func (*Bayes) Classify

func (b *Bayes) Classify(words []string) (string, float64)

Classify 情感分析分类

func (*Bayes) GetCategory

func (b *Bayes) GetCategory(cat string) *Probe

GetCategory 获取分类的Probe

func (*Bayes) GetSum

func (b *Bayes) GetSum() float64

GetSum 获取total

func (*Bayes) Iter

func (b *Bayes) Iter() <-chan *Probe

Iter data iterator

func (*Bayes) Len

func (b *Bayes) Len() int

Len get total number of categories

func (*Bayes) Save

func (b *Bayes) Save(w io.Writer) error

Save save model

func (*Bayes) SaveFile

func (b *Bayes) SaveFile(loc string) error

SaveFile save model to a file

func (*Bayes) ToModel

func (b *Bayes) ToModel() Model

ToModel 转换为模型

type Model

type Model struct {
	Total float64          `json:"total,omitempty"`
	Data  map[string]Probe `json:"d,omitempty"`
}

Model bayes model for saving

type Probe

type Probe struct {
	Category string             `json:"-"`
	Total    float64            `json:'total,omitempty'`
	Data     map[string]float64 `json:"d,omitempty"`
	None     float64            `json:"none,omitempty"`
	// contains filtered or unexported fields
}

Probe 单个分类内词频

func NewProbe

func NewProbe() *Probe

NewProbe 新建Probe

func (*Probe) Add

func (a *Probe) Add(key string, value float64)

func (*Probe) AddWords

func (a *Probe) AddWords(words map[string]float64)

func (*Probe) Exists

func (a *Probe) Exists(key string) bool

Exists 判断key是否存在

func (*Probe) Freq

func (a *Probe) Freq(key string) float64

Freq 获取key词频

func (*Probe) Get

func (a *Probe) Get(key string) float64

Get 获取key值

func (*Probe) GetSum

func (a *Probe) GetSum() float64

GetSum 获取total

Jump to

Keyboard shortcuts

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