func NewBayesianAnalyzer(traningDataFilePath string, dictDataFilePath string) (*BayesianAnalyzer, error) { tokenizer, err := goseg.NewTokenizerFromFile(dictDataFilePath) if err != nil { return nil, err } coordinator := &sync.RWMutex{} classifier, err := bayesian.NewClassifierFromFile(traningDataFilePath) if err != nil { return nil, err } return &BayesianAnalyzer{tokenizer, classifier, nil, coordinator}, nil }
func NewBayesianAnalyzerWithUpdater(traningDataFilePath string, dictDataFilePath string, updateDelay time.Duration) (*BayesianAnalyzer, error) { tokenizer, err := goseg.NewTokenizerFromFile(dictDataFilePath) if err != nil { return nil, err } coordinator := &sync.RWMutex{} classifier, err := bayesian.NewClassifierFromFile(traningDataFilePath) if err != nil { return nil, err } updater := NewDelayedUpdater(classifier, traningDataFilePath, updateDelay, coordinator) return &BayesianAnalyzer{tokenizer, classifier, updater, coordinator}, nil }