github.com/weaviate/weaviate@v1.24.6/modules/ner-transformers/additional/tokens/tokens_params_extractor.go (about) 1 // _ _ 2 // __ _____ __ ___ ___ __ _| |_ ___ 3 // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ 4 // \ V V / __/ (_| |\ V /| | (_| | || __/ 5 // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| 6 // 7 // Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. 8 // 9 // CONTACT: hello@weaviate.io 10 // 11 12 package tokens 13 14 import ( 15 "strconv" 16 17 "github.com/tailor-inc/graphql/language/ast" 18 ) 19 20 func (p *TokenProvider) parseTokenArguments(args []*ast.Argument) *Params { 21 out := &Params{} 22 23 for _, arg := range args { 24 switch arg.Name.Value { 25 case "limit": 26 asInt, _ := strconv.Atoi(arg.Value.GetValue().(string)) 27 out.Limit = ptInt(asInt) 28 case "certainty": 29 asFloat, _ := strconv.ParseFloat(arg.Value.GetValue().(string), 64) 30 out.Certainty = &asFloat 31 case "distance": 32 asFloat, _ := strconv.ParseFloat(arg.Value.GetValue().(string), 64) 33 out.Distance = &asFloat 34 case "properties": 35 inp := arg.Value.GetValue().([]ast.Value) 36 out.Properties = make([]string, len(inp)) 37 38 for i, value := range inp { 39 out.Properties[i] = value.(*ast.StringValue).Value 40 } 41 42 default: 43 // ignore what we don't recognize 44 } 45 } 46 47 return out 48 } 49 50 func ptInt(in int) *int { 51 return &in 52 }