service/library/contentaudit/textaudit/simulate.go

88 lines
3.0 KiB
Go
Raw Permalink Normal View History

2023-12-21 22:17:40 +08:00
package textaudit
import (
textaudit "github.com/alibabacloud-go/imageaudit-20191230/v3/client"
"github.com/alibabacloud-go/tea/tea"
)
func TextAudit(req *textaudit.ScanTextRequest) (resp *textaudit.ScanTextResponse, err error) {
elements := make([]*textaudit.ScanTextResponseBodyDataElements, len(req.Tasks))
for i := range elements {
elements[i] = &textaudit.ScanTextResponseBodyDataElements{}
element := elements[i]
if i == 0 {
element.Results = make([]*textaudit.ScanTextResponseBodyDataElementsResults, 1)
for i := range element.Results {
element.Results[i] = &textaudit.ScanTextResponseBodyDataElementsResults{}
}
element.Results[0].Suggestion = tea.String("pass")
element.Results[0].Label = tea.String("normal")
element.Results[0].Rate = tea.Float32(99.9)
}
if i == 1 {
element.Results = make([]*textaudit.ScanTextResponseBodyDataElementsResults, 1)
for i := range element.Results {
element.Results[i] = &textaudit.ScanTextResponseBodyDataElementsResults{}
}
element.Results[0].Suggestion = tea.String("block")
element.Results[0].Label = tea.String("porn")
element.Results[0].Rate = tea.Float32(99.9)
details := make([]*textaudit.ScanTextResponseBodyDataElementsResultsDetails, 1)
contexts := make([]*textaudit.ScanTextResponseBodyDataElementsResultsDetailsContexts, 1)
contexts[0] = &textaudit.ScanTextResponseBodyDataElementsResultsDetailsContexts{
Context: tea.String("这是一条porn信息"),
}
details[0] = &textaudit.ScanTextResponseBodyDataElementsResultsDetails{
Label: tea.String("porn"),
Contexts: contexts,
}
element.Results[0].Details = details
}
if i == 2 {
element.Results = make([]*textaudit.ScanTextResponseBodyDataElementsResults, 1)
for i := range element.Results {
element.Results[i] = &textaudit.ScanTextResponseBodyDataElementsResults{}
}
element.Results[0].Suggestion = tea.String("pass")
element.Results[0].Label = tea.String("normal")
element.Results[0].Rate = tea.Float32(99.9)
}
if i == 3 {
element.Results = make([]*textaudit.ScanTextResponseBodyDataElementsResults, 1)
for i := range element.Results {
element.Results[i] = &textaudit.ScanTextResponseBodyDataElementsResults{}
}
element.Results[0].Suggestion = tea.String("block")
element.Results[0].Label = tea.String("ad")
element.Results[0].Rate = tea.Float32(99.9)
details := make([]*textaudit.ScanTextResponseBodyDataElementsResultsDetails, 1)
contexts := make([]*textaudit.ScanTextResponseBodyDataElementsResultsDetailsContexts, 1)
contexts[0] = &textaudit.ScanTextResponseBodyDataElementsResultsDetailsContexts{
Context: tea.String("这是一条ad信息"),
}
details[0] = &textaudit.ScanTextResponseBodyDataElementsResultsDetails{
Label: tea.String("ad"),
Contexts: contexts,
}
element.Results[0].Details = details
}
}
body := &textaudit.ScanTextResponseBody{
RequestId: tea.String("114514"),
Data: &textaudit.ScanTextResponseBodyData{
Elements: elements,
},
}
resp = &textaudit.ScanTextResponse{
Body: body,
}
return
}