Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AliyunTextCensor ¶
type AliyunTextCensor struct {
// contains filtered or unexported fields
}
func NewAliyunTextCensor ¶
func NewAliyunTextCensor(accessKey, accessKeySecret string) *AliyunTextCensor
func (*AliyunTextCensor) Censor ¶
func (c *AliyunTextCensor) Censor(_ context.Context, text string) (*TextCensorResponse, error)
Censor censors text with Aliyun API. https://developer.qiniu.com/censor/7260/api-text-censor
func (*AliyunTextCensor) String ¶
func (*AliyunTextCensor) String() string
type AliyunTextCensorResponse ¶
type AliyunTextCensorResponse struct { Code int `json:"code"` Data []struct { Code int `json:"code"` Content string `json:"content"` FilteredContent string `json:"filteredContent"` Msg string `json:"msg"` Results []struct { Details []struct { Contexts []struct { Context string `json:"context"` Positions []struct { EndPos int `json:"endPos"` StartPos int `json:"startPos"` } `json:"positions"` } `json:"contexts"` Label string `json:"label"` } `json:"details"` Label string `json:"label"` Rate float64 `json:"rate"` Scene string `json:"scene"` Suggestion string `json:"suggestion"` } `json:"results"` TaskId string `json:"taskId"` } `json:"data"` Msg string `json:"msg"` RequestId string `json:"requestId"` }
func (*AliyunTextCensorResponse) IsPass ¶
func (r *AliyunTextCensorResponse) IsPass() bool
type ForbiddenType ¶
type ForbiddenType string
const ( ForbiddenTypeSpam ForbiddenType = "spam" ForbiddenTypeAd ForbiddenType = "ad" ForbiddenTypePolitics ForbiddenType = "politics" ForbiddenTypeTerrorism ForbiddenType = "terrorism" ForbiddenTypeAbuse ForbiddenType = "abuse" ForbiddenTypePorn ForbiddenType = "porn" ForbiddenTypeFlood ForbiddenType = "flood" ForbiddenTypeContraband ForbiddenType = "contraband" ForbiddenTypeMeaningless ForbiddenType = "meaningless" ForbiddenTypeHarmful ForbiddenType = "harmful" )
func (ForbiddenType) String ¶
func (f ForbiddenType) String() string
type QiniuTextCensor ¶
type QiniuTextCensor struct {
// contains filtered or unexported fields
}
func NewQiniuTextCensor ¶
func NewQiniuTextCensor(accessKey, accessSecret string) *QiniuTextCensor
func (*QiniuTextCensor) Censor ¶
func (c *QiniuTextCensor) Censor(ctx context.Context, text string) (*TextCensorResponse, error)
Censor censors text with Qiniu API. https://developer.qiniu.com/censor/7260/api-text-censor
func (*QiniuTextCensor) String ¶
func (*QiniuTextCensor) String() string
type QiniuTextCensorResponse ¶
type QiniuTextCensorResponse struct { Code int `json:"code"` Message string `json:"message"` Result struct { Suggestion string `json:"suggestion"` Scenes struct { Antispam struct { Suggestion string `json:"suggestion"` Details []struct { Label string `json:"label"` Score float64 `json:"score"` Contexts []struct { Context string `json:"context"` Positions []struct { StartPos int `json:"startPos"` EndPos int `json:"endPos"` } `json:"positions"` } `json:"contexts"` } `json:"details"` } `json:"antispam"` } `json:"scenes"` } `json:"result"` }
func (*QiniuTextCensorResponse) IsPass ¶
func (r *QiniuTextCensorResponse) IsPass() bool
type TextCensor ¶
type TextCensorResponse ¶
type TextCensorResponse struct { SourceName string `json:"source_name"` Pass bool `json:"pass"` ForbiddenType ForbiddenType `json:"forbidden_type"` Hint string `json:"hint"` Confidence float64 `json:"confidence"` RawResponse json.RawMessage `json:"raw_response"` }
func AliyunTextCensorParser ¶
func AliyunTextCensorParser(raw []byte) (*TextCensorResponse, error)
func QiniuTextCensorParser ¶
func QiniuTextCensorParser(raw []byte) (*TextCensorResponse, error)
func Text ¶
func Text(ctx context.Context, text string) (*TextCensorResponse, error)
Text checks the text for sensitive content. It will save the censor log to the database and invoke the callback function.
func (*TextCensorResponse) ErrorMessage ¶
func (r *TextCensorResponse) ErrorMessage() string
func (*TextCensorResponse) ToJSON ¶
func (r *TextCensorResponse) ToJSON() []byte
Click to show internal directories.
Click to hide internal directories.