nlp_classifier

package
v0.3.41 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: BSD-3-Clause Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MatchLevelAll  = "all"
	MatchLevelAny  = "any"
	MatchLevelBest = "best"
)

Variables

View Source
var (
	MissingTextError = errors.New("missing_text_error")
	MissingTagsError = errors.New("missing_tags_error")
)

Functions

This section is empty.

Types

type NlpClassificationCategory

type NlpClassificationCategory struct {
	Name string   `json:"name"`
	Tags []string `json:"tags"`
}

type NlpClassificationOptions

type NlpClassificationOptions struct {
	DetectLanguage      bool                         `json:"detect-lang"`
	DetectKeywordsMode  string                       `json:"detect-keywords-mode"` // all, unique, none
	DetectEntities      []string                     `json:"detect-entities"`
	SummarizerSentences int                          `json:"summarizer-sentences"`
	MatchLevel          string                       `json:"match-level"` // all, any, best
	Categories          []*NlpClassificationCategory `json:"categories"`
}

func ParseOptionsFromJson

func ParseOptionsFromJson(text string) (options *NlpClassificationOptions, err error)

type NlpClassificationOutput

type NlpClassificationOutput struct {
	Language string                       `json:"language"`
	Entities map[string][]string          `json:"entities"`
	Summary  string                       `json:"summary"`
	Response []*NlpClassificationResponse `json:"response"`
	Error    string                       `json:"error"`
}

func (*NlpClassificationOutput) HasError

func (instance *NlpClassificationOutput) HasError() bool

func (*NlpClassificationOutput) SortAsc

func (instance *NlpClassificationOutput) SortAsc() *NlpClassificationOutput

func (*NlpClassificationOutput) SortDesc

func (instance *NlpClassificationOutput) SortDesc() *NlpClassificationOutput

func (*NlpClassificationOutput) String

func (instance *NlpClassificationOutput) String() string

type NlpClassificationResponse

type NlpClassificationResponse struct {
	Language string   `json:"language"`
	Category string   `json:"category"`
	Score    float32  `json:"score"`
	Keywords []string `json:"keywords"`
}

type NlpClassifier

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

func NewNlpClassifier

func NewNlpClassifier() (instance *NlpClassifier)

func (*NlpClassifier) Classify

func (instance *NlpClassifier) Classify(text string, options *NlpClassificationOptions) (out *NlpClassificationOutput, err error)

func (*NlpClassifier) MatchKeywordsAll

func (instance *NlpClassifier) MatchKeywordsAll(text string, tags []string) (keywords []string)

func (*NlpClassifier) MatchKeywordsUnique

func (instance *NlpClassifier) MatchKeywordsUnique(text string, tags []string) (keywords []string)

func (*NlpClassifier) Score

func (instance *NlpClassifier) Score(text, level string, tags []string) (score float32, err error)

Jump to

Keyboard shortcuts

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