contentSafe

package module
v0.0.0-...-7dbae93 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: BSD-3-Clause Imports: 21 Imported by: 1

README

内容安全的包 后端在这里 需要部署好后端才行

  • 主要是图片检测

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractChinese

func ExtractChinese(word string) string

ExtractChinese 提取出中文 包括繁体

func ExtractEnglish

func ExtractEnglish(word string) string

ExtractEnglish 提取出所有英文 包括大小写

func PruneText

func PruneText(word string) (string, string)

PruneText 获取纯文本

func Tc2Cn

func Tc2Cn(word string) string

Tc2Cn 繁体转简体

Types

type ContentSafe

type ContentSafe struct {
	NsfwHost    string
	TmpSaveBase string
	// contains filtered or unexported fields
}
var (
	C *ContentSafe
)

func NewSafeClient

func NewSafeClient() *ContentSafe

func (*ContentSafe) AddWords

func (c *ContentSafe) AddWords(wordList ...string)

func (*ContentSafe) AutoHitImg

func (c *ContentSafe) AutoHitImg(uri string) (bool, error)

AutoHitImg 检测是否为正常图片

func (*ContentSafe) AutoHitText

func (c *ContentSafe) AutoHitText(content string) (success bool, message string)

func (*ContentSafe) ClearText

func (c *ContentSafe) ClearText(words string) string

func (*ContentSafe) DownloadImage

func (c *ContentSafe) DownloadImage(remoteUri string) (savePath string, fileName string, err error)

func (*ContentSafe) FetchNsfw

func (c *ContentSafe) FetchNsfw(remoteUri string) (*Prediction, error)

func (*ContentSafe) GetToken

func (c *ContentSafe) GetToken() string

func (*ContentSafe) HitImgHandler

func (c *ContentSafe) HitImgHandler(ctx iris.Context)

func (*ContentSafe) HitText

func (c *ContentSafe) HitText(content string) (bool, string)

func (*ContentSafe) HitTextHandler

func (c *ContentSafe) HitTextHandler(ctx iris.Context)

func (*ContentSafe) InitLadClient

func (c *ContentSafe) InitLadClient() error

func (*ContentSafe) RegistryRouters

func (c *ContentSafe) RegistryRouters(party iris.Party)

func (*ContentSafe) SetGetTokenFunc

func (c *ContentSafe) SetGetTokenFunc(getTokenFunc func() string)

func (*ContentSafe) WxImgCheckV1

func (c *ContentSafe) WxImgCheckV1(remoteUri string) (bool, error)

WxImgCheckV1 返回的是 是否为正常图片

func (*ContentSafe) WxTextCheckV1

func (c *ContentSafe) WxTextCheckV1(content string) (bool, error, string)

type HitImgReq

type HitImgReq struct {
	Uri string `json:"uri" form:"uri" comment:"图片地址" validate:"required"`
}

type Prediction

type Prediction struct {
	Drawings float32 `json:"drawings"` // 无害的艺术,或艺术绘画 最高100分
	Hentai   float32 `json:"hentai"`   // 色情艺术,不适合大多数工作环境
	Neutral  float32 `json:"neutral"`  // 一般,无害的内容
	Porn     float32 `json:"porn"`     // 不雅的内容和行为,通常涉及生殖器 性行为等
	Sexy     float32 `json:"sexy"`     // 性感 但无色情
}

func (*Prediction) IsNsfw

func (c *Prediction) IsNsfw() bool

type WordHitResp

type WordHitResp struct {
	Success bool   `json:"success"`
	Msg     string `json:"msg"`
}

type WordValidReq

type WordValidReq struct {
	Content string `json:"content" comment:"内容" validate:"required,max=2000"` // 尽量不要有长字符
}

type WxImgV1Resp

type WxImgV1Resp struct {
	Errcode int    `json:"errcode"`
	Errmsg  string `json:"errmsg"`
}

type WxTextV1Resp

type WxTextV1Resp struct {
	Errcode int    `json:"errcode"`
	Errmsg  string `json:"errmsg"`
	TraceId string `json:"trace_id"`
}

Jump to

Keyboard shortcuts

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