github.com/weaviate/weaviate@v1.24.6/modules/text2vec-contextionary/vectorizer/fakes_for_test.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 vectorizer 13 14 import ( 15 "context" 16 17 txt2vecmodels "github.com/weaviate/weaviate/modules/text2vec-contextionary/additional/models" 18 ) 19 20 type fakeClient struct { 21 lastInput []string 22 } 23 24 func (c *fakeClient) VectorForCorpi(ctx context.Context, corpi []string, overrides map[string]string) ([]float32, []txt2vecmodels.InterpretationSource, error) { 25 c.lastInput = corpi 26 return []float32{0, 1, 2, 3}, nil, nil 27 } 28 29 func (c *fakeClient) VectorForWord(ctx context.Context, word string) ([]float32, error) { 30 c.lastInput = []string{word} 31 return []float32{3, 2, 1, 0}, nil 32 } 33 34 func (c *fakeClient) NearestWordsByVector(ctx context.Context, 35 vector []float32, n int, k int, 36 ) ([]string, []float32, error) { 37 return []string{"word1", "word2"}, []float32{0.1, 0.2}, nil 38 } 39 40 func (c *fakeClient) IsWordPresent(ctx context.Context, word string) (bool, error) { 41 return true, nil 42 } 43 44 type fakeClassConfig struct { 45 classConfig map[string]interface{} 46 vectorizePropertyName bool 47 skippedProperty string 48 vectorizeClassName bool 49 excludedProperty string 50 } 51 52 func (f fakeClassConfig) Class() map[string]interface{} { 53 classSettings := map[string]interface{}{ 54 "vectorizeClassName": f.vectorizeClassName, 55 } 56 return classSettings 57 } 58 59 func (f fakeClassConfig) ClassByModuleName(moduleName string) map[string]interface{} { 60 return f.classConfig 61 } 62 63 func (f fakeClassConfig) Property(propName string) map[string]interface{} { 64 if propName == f.skippedProperty { 65 return map[string]interface{}{ 66 "skip": true, 67 } 68 } 69 if propName == f.excludedProperty { 70 return map[string]interface{}{ 71 "vectorizePropertyName": false, 72 } 73 } 74 if f.vectorizePropertyName { 75 return map[string]interface{}{ 76 "vectorizePropertyName": true, 77 } 78 } 79 return nil 80 } 81 82 func (f fakeClassConfig) Tenant() string { 83 return "" 84 } 85 86 func (f fakeClassConfig) TargetVector() string { 87 return "" 88 }