bot

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CORPUS_TYPE

type CORPUS_TYPE int
const (
	CORPUS_CORPUS      CORPUS_TYPE = 1
	CORPUS_REQUIREMENT CORPUS_TYPE = 2
)

type ChatBot

type ChatBot struct {
	PrintMemStats bool
	//InputAdapter   input.InputAdapter
	LogicAdapter logic.LogicAdapter
	//OutputAdapter  output.OutputAdapter
	StorageAdapter storage.StorageAdapter
	Trainer        Trainer
	Config         Config
}

func (*ChatBot) AddCorpusToDB

func (chatbot *ChatBot) AddCorpusToDB(corpus *Corpus) error

func (*ChatBot) AddFeedbackToDB

func (chatbot *ChatBot) AddFeedbackToDB(feedback *Feedback) error

func (*ChatBot) FindCorporaFiles

func (chatbot *ChatBot) FindCorporaFiles(dir string) []string

func (*ChatBot) GetResponse

func (chatbot *ChatBot) GetResponse(text string, context ...string) []logic.Answer

func (*ChatBot) Init

func (chatbot *ChatBot) Init()

func (*ChatBot) LoadCorpusFromDB

func (chatbot *ChatBot) LoadCorpusFromDB() (map[string][][]string, error)

func (*ChatBot) LoadCorpusFromFiles

func (chatbot *ChatBot) LoadCorpusFromFiles(filePaths []string) (map[string][][]string, error)

func (*ChatBot) RemoveCorpusFromDB

func (chatbot *ChatBot) RemoveCorpusFromDB(corpus *Corpus) error

func (*ChatBot) SaveCorpusToDB

func (chatbot *ChatBot) SaveCorpusToDB(corpuses map[string][][]string)

func (*ChatBot) Train

func (chatbot *ChatBot) Train(data interface{}) error

func (*ChatBot) TrainWithDB

func (chatbot *ChatBot) TrainWithDB() error

type ChatBotFactory

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

func NewChatBotFactory

func NewChatBotFactory(config Config) *ChatBotFactory

func (*ChatBotFactory) AddChatBot

func (f *ChatBotFactory) AddChatBot(project string, chatBot *ChatBot)

func (*ChatBotFactory) AddProject

func (f *ChatBotFactory) AddProject(name, config string) (*Project, error)

func (*ChatBotFactory) GetChatBot

func (f *ChatBotFactory) GetChatBot(project string) (*ChatBot, bool)

func (*ChatBotFactory) GetCorpusById

func (f *ChatBotFactory) GetCorpusById(id int) *Corpus

func (*ChatBotFactory) GetProject

func (f *ChatBotFactory) GetProject(name string) (bool, error)

func (*ChatBotFactory) Init

func (f *ChatBotFactory) Init()

func (*ChatBotFactory) ListCorpus

func (f *ChatBotFactory) ListCorpus(corpus Corpus, start int, limit int) []Corpus

func (*ChatBotFactory) ListProject

func (f *ChatBotFactory) ListProject() []Project

func (*ChatBotFactory) Refresh

func (f *ChatBotFactory) Refresh()

func (*ChatBotFactory) UpdateCorpusCounter

func (chatbot *ChatBotFactory) UpdateCorpusCounter(id int, isOk bool) error

type Config

type Config struct {
	Driver        string `json:"driver"`
	DataSource    string `json:"data_source"`
	Project       string `json:"project"`
	DirCorpus     string `json:"dir_corpus"`
	StoreFile     string `json:"store_file"`
	PrintMemStats bool   `json:"print_mem_stats"`
}

type ConversationTrainer

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

func NewConversationTrainer

func NewConversationTrainer(storage storage.StorageAdapter) *ConversationTrainer

func (*ConversationTrainer) Train

func (trainer *ConversationTrainer) Train(data interface{}) error

type Corpus

type Corpus struct {
	Id       int    `json:"id" form:"id" xorm:"int pk autoincr notnull 'id' comment('编号')"`
	Class    string `json:"class" form:"class"  xorm:"varchar(255) notnull 'class' comment('分类')"`
	Project  string `json:"project" form:"project" xorm:"varchar(255) notnull 'project' comment('项目')"`
	Question string `json:"question" form:"question"  xorm:"varchar(2048) notnull  'question' comment('问题')"`
	Answer   string `json:"answer" form:"answer" xorm:"text notnull  'answer' comment('回答')"`
	//Creator     string    `json:"creator" form:"creator" xorm:"varchar(256) notnull  'creator' comment('创建人')"`
	Principal   string     `json:"principal" form:"principal" xorm:"varchar(256) notnull  'principal' comment('责负人')"`
	Reviser     string     `json:"reviser" form:"reviser" xorm:"varchar(256) notnull  'reviser' comment('修订人')"`
	AcceptCount int        `json:"accept_count" form:"accept_count" xorm:"int notnull default 0  'accept_count' comment('解决次数')"`
	RejectCount int        `json:"reject_count" form:"reject_count" xorm:"int notnull  default 0 'reject_count' comment('解决次数')"`
	CreatTime   time.Time  `json:"creat_time" xorm:"creat_time created" json:"creat_time" description:"创建时间"`
	UpdateTime  time.Time  `json:"update_time" xorm:"update_time updated"json:"update_time"description:"更新时间"`
	Qtype       int        `json:"qtype" form:"qtype" xorm:"int notnull 'qtype' comment('类型,需求,问答')"`
	Context     string     `json:"context" form:"context" xorm:"varchar(255) notnull default '' 'context' comment('Context after answer')"`
	Contextual  bool       `json:"contextual" form:"contextual" xorm:"int(1) not null default 0 'contextual' comment('Is this conversation contextual')"`
	Data        CorpusData `json:"data" form:"data" xorm:"text notnull default '' 'data' comment('Data')"`
}

type CorpusData

type CorpusData struct {
	Data map[string]interface{}
}

func (*CorpusData) FromDB

func (corpusData *CorpusData) FromDB(data []byte) error

func (*CorpusData) ToDB

func (corpusData *CorpusData) ToDB() ([]byte, error)

type CorpusTrainer

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

func NewCorpusTrainer

func NewCorpusTrainer(storage storage.StorageAdapter) *CorpusTrainer

func (*CorpusTrainer) Train

func (trainer *CorpusTrainer) Train(data interface{}) error

func (*CorpusTrainer) TrainWithCorpus

func (trainer *CorpusTrainer) TrainWithCorpus(corpuses map[string][][]string) error

type Feedback

type Feedback struct {
	Id          int       `json:"id" form:"id" xorm:"int pk autoincr notnull 'id' comment('编号')"`
	Cid         int       `json:"cid" form:"cid" xorm:"int  notnull 'cid' comment('语料编号')"`
	Class       string    `json:"class" form:"class"  xorm:"varchar(255) notnull 'class' comment('分类')"`
	Project     string    `json:"project" form:"project" xorm:"varchar(255) notnull 'project' comment('项目')"`
	Question    string    `json:"question" form:"question"  xorm:"varchar(2048) notnull  'question' comment('问题')"`
	Answer      string    `json:"answer" form:"answer" xorm:"text notnull   'answer' comment('回答')"`
	Creator     string    `json:"creator" form:"creator" xorm:"varchar(256) notnull  'creator' comment('创建人')"`
	Principal   string    `json:"principal" form:"principal" xorm:"varchar(256) notnull  'principal' comment('责负人')"`
	Reviser     string    `json:"reviser" form:"reviser" xorm:"varchar(256) notnull  'reviser' comment('修订人')"`
	AcceptCount int       `json:"accept_count" form:"accept_count" xorm:"int notnull default 0  'accept_count' comment('解决次数')"`
	RejectCount int       `json:"reject_count" form:"reject_count" xorm:"int notnull default 0  'reject_count' comment('解决次数')"`
	CreatTime   time.Time `json:"creat_time" xorm:"creat_time created" json:"creat_time" description:"创建时间"`
	UpdateTime  time.Time `json:"update_time" xorm:"update_time updated"json:"update_time"description:"更新时间"`
	Qtype       int       `json:"qtype" form:"qtype" xorm:"int notnull 'qtype' comment('类型,需求,问答')"`
}

type Project

type Project struct {
	Id     int    `json:"id" form:"id" xorm:"int pk autoincr notnull 'id' comment('编号')"`
	Name   string `json:"name" form:"name"  xorm:"varchar(255) notnull 'name' comment('名称')"`
	Config string `json:"config" form:"config"  xorm:"text notnull 'config' comment('配置')"`
}

type Trainer

type Trainer interface {
	Train(interface{}) error
	TrainWithCorpus(corpuses map[string][][]string) error
}

Directories

Path Synopsis
adapters

Jump to

Keyboard shortcuts

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