nlp

package
v1.0.118 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceName    = "nlp_gateway"
	ApiVersion1    = "2020-09-01"
	ApiVersion2    = "2020-12-01"
	DefaultTimeout = 10 * time.Second
)

Variables

View Source
var (
	ServiceInfoMap = map[string]*base.ServiceInfo{
		base.RegionCnNorth1: {
			Timeout: 10 * time.Second,
			Scheme:  "https",
			Host:    "open.volcengineapi.com",
			Header: http.Header{
				"Accept": []string{"application/json"},
			},
			Credentials: base.Credentials{
				Region:  base.RegionCnNorth1,
				Service: ServiceName,
			},
		},
	}
	ApiInfoList = map[string]*base.ApiInfo{

		"TextCorrectionZhCorrect": {
			Method: http.MethodPost,
			Path:   "/",
			Query: url.Values{
				"Action":  []string{"TextCorrectionZhCorrect"},
				"Version": []string{ApiVersion1},
			},
		},

		"TextCorrectionEnCorrect": {
			Method: http.MethodPost,
			Path:   "/",
			Query: url.Values{
				"Action":  []string{"TextCorrectionEnCorrect"},
				"Version": []string{ApiVersion1},
			},
		},

		"SentimentAnalysis": {
			Method: http.MethodPost,
			Path:   "/",
			Query: url.Values{
				"Action":  []string{"SentimentAnalysis"},
				"Version": []string{ApiVersion2},
			},
		},

		"TextSummarization": {
			Method: http.MethodPost,
			Path:   "/",
			Query: url.Values{
				"Action":  []string{"TextSummarization"},
				"Version": []string{ApiVersion2},
			},
		},

		"KeyphraseExtractionExtract": {
			Method: http.MethodPost,
			Path:   "/",
			Query: url.Values{
				"Action":  []string{"KeyphraseExtractionExtract"},
				"Version": []string{ApiVersion1},
			},
		},
	}
)
View Source
var DefaultInstance = NewInstance()

DefaultInstance 默认实例,Region: cn-north-1

Functions

func UnmarshalResultInto

func UnmarshalResultInto(data []byte, result interface{}) error

Types

type CharResult

type CharResult struct {
	Correct    string  `json:"correct"`
	Original   string  `json:"original"`
	IndexOfDoc int     `json:"index_of_doc"`
	Confidence float64 `json:"confidence"`
}

type EnCorrectResultItem

type EnCorrectResultItem struct {
	Correct    string `json:"correct"`
	Original   string `json:"original"`
	IndexOfDoc int    `json:"index_of_doc"`
}

type ErrorResult

type ErrorResult struct {
	Message string `json:"message"`
}

type KeyPhraseExtractionParam

type KeyPhraseExtractionParam struct {
	RequestType string `json:"request_type"`
	Title       string `json:"title"`
	Content     string `json:"content"`
}

type KeyPhraseExtractionResult

type KeyPhraseExtractionResult struct {
	Keywords []KeywordItem `json:"keywords"`
}

type KeywordItem

type KeywordItem struct {
	Text     string   `json:"text"`
	Weight   float64  `json:"weight"`
	Fullname string   `json:"fullname"`
	Category []string `json:"category"`
}

type Nlp

type Nlp struct {
	*base.Client
}

func NewInstance

func NewInstance() *Nlp

func (*Nlp) GetKeyPhraseExtractionExtract

func (c *Nlp) GetKeyPhraseExtractionExtract(param *KeyPhraseExtractionParam) (*KeyPhraseExtractionResult, error)

关键词提取

func (*Nlp) GetSentimentAnalysis

func (c *Nlp) GetSentimentAnalysis(param *SentimentAnalysisParam) (*SentimentAnalysisResult, error)

情感分析

func (*Nlp) GetTextCorrectionEnCorrect

func (c *Nlp) GetTextCorrectionEnCorrect(param *TextCorrectionEnCorrectParam) (*TextCorrectionEnCorrectResult, error)

英文文本纠错

func (*Nlp) GetTextCorrectionZhCorrect

func (c *Nlp) GetTextCorrectionZhCorrect(param *TextCorrectionZhCorrectParam) (*TextCorrectionZhCorrectResult, error)

中文文本纠错

func (*Nlp) GetTextSummarization

func (c *Nlp) GetTextSummarization(param *TextSummarizationParam) (*TextSummarizationResult, error)

文本摘要

func (*Nlp) NlpPost

func (c *Nlp) NlpPost(action string, query url.Values, req, result interface{}) error

type SentimentAnalysisParam

type SentimentAnalysisParam struct {
	Text string `json:"text"`
}

type SentimentAnalysisResult

type SentimentAnalysisResult struct {
	Result        string `json:"result"`
	PositiveScore string `json:"positive_score"`
	NegativeScore string `json:"negative_score"`
}

type TextCorrectionEnCorrectParam

type TextCorrectionEnCorrectParam struct {
	Content string `json:"content"`
}

type TextCorrectionEnCorrectResult

type TextCorrectionEnCorrectResult struct {
	Result []EnCorrectResultItem `json:"result"`
}

type TextCorrectionZhCorrectParam

type TextCorrectionZhCorrectParam struct {
	Content string `json:"content"`
}

type TextCorrectionZhCorrectResult

type TextCorrectionZhCorrectResult struct {
	CharResult []CharResult `json:"char_result"`
	WordResult []WordResult `json:"word_result"`
}

type TextSummarizationParam

type TextSummarizationParam struct {
	Text string `json:"text"`
}

type TextSummarizationResult

type TextSummarizationResult struct {
	Result string `json:"result"`
}

type WordResult

type WordResult struct {
	Correct    string  `json:"correct"`
	Original   string  `json:"original"`
	IndexOfDoc int     `json:"index_of_doc"`
	Confidence float64 `json:"confidence"`
}

Jump to

Keyboard shortcuts

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