Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2021-10-28 13:41:00 +00:00
parent ec8910b174
commit fced949d94
43 changed files with 4129 additions and 0 deletions

35
go/sentiment/sentiment.go Executable file
View File

@@ -0,0 +1,35 @@
package sentiment
import (
"github.com/m3o/m3o-go/client"
)
func NewSentimentService(token string) *SentimentService {
return &SentimentService{
client: client.NewClient(&client.Options{
Token: token,
}),
}
}
type SentimentService struct {
client *client.Client
}
// Analyze and score a piece of text
func (t *SentimentService) Analyze(request *AnalyzeRequest) (*AnalyzeResponse, error) {
rsp := &AnalyzeResponse{}
return rsp, t.client.Call("sentiment", "Analyze", request, rsp)
}
type AnalyzeRequest struct {
// The language. Defaults to english.
Lang string `json:"lang"`
// The text to analyze
Text string `json:"text"`
}
type AnalyzeResponse struct {
// The score of the text {positive is 1, negative is 0}
Score float64 `json:"score"`
}