如何在 DetectEntitiesOutput 中仅过滤组织实体?
How to filter Only Organization entities in DetectEntitiesOutput?
我是 Go 语言的新手,正在尝试学习它,所以请原谅任何明显的问题,但需要一些帮助..
问题:我正在尝试仅过滤 Comprehend 在 DetectEntitiesOutput 中返回的组织实体。
我的导入如下
"errors"
"fmt"
"strings"
"github.com/aws/aws-lambda-go/lambda"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/comprehend"
func Filter(vs []Entity, f func(Entity) bool) []Entity {
vsf := make([]Entity, 0)
for _, v := range vs {
if f(v) {
vsf = append(vsf, v)
}
}
return vsf
}
func isOrg(vs Entity) bool {
return strings.EqualFold(Entity.Type, "ORGANIZATION")
}```
But i am getting following error ./main.go:52:18: undefined: Entity
./main.go:53:16: undefined: Entity
./main.go:62:15: undefined: Entity
./main.go:63:27: undefined: Entity
Can someone help?
编译器找不到 Entity
结构的定义。确保它存在于同一个包中,或者如果它来自不同的包,您可以将 Entity
替换为 packageName.Entity
.
我是 Go 语言的新手,正在尝试学习它,所以请原谅任何明显的问题,但需要一些帮助..
问题:我正在尝试仅过滤 Comprehend 在 DetectEntitiesOutput 中返回的组织实体。
我的导入如下
"errors"
"fmt"
"strings"
"github.com/aws/aws-lambda-go/lambda"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/comprehend"
func Filter(vs []Entity, f func(Entity) bool) []Entity {
vsf := make([]Entity, 0)
for _, v := range vs {
if f(v) {
vsf = append(vsf, v)
}
}
return vsf
}
func isOrg(vs Entity) bool {
return strings.EqualFold(Entity.Type, "ORGANIZATION")
}```
But i am getting following error ./main.go:52:18: undefined: Entity
./main.go:53:16: undefined: Entity
./main.go:62:15: undefined: Entity
./main.go:63:27: undefined: Entity
Can someone help?
编译器找不到 Entity
结构的定义。确保它存在于同一个包中,或者如果它来自不同的包,您可以将 Entity
替换为 packageName.Entity
.