github.com/weaviate/weaviate@v1.24.6/modules/text2vec-contextionary/vectorizer/noop.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  	"github.com/weaviate/weaviate/entities/models"
    18  )
    19  
    20  // NoOpVectorizer is a simple stand in that does nothing. Can be used when the
    21  // feature should be turned off overall
    22  type NoOpVectorizer struct{}
    23  
    24  // Corpi is not implemented in the NoOpVectorizer
    25  func (n *NoOpVectorizer) Corpi(ctx context.Context, corpi []string) ([]float32, error) {
    26  	return []float32{}, nil
    27  }
    28  
    29  // MoveTo is not implemented in the NoOpVectorizer
    30  func (n *NoOpVectorizer) MoveTo(source []float32, target []float32, weight float32) ([]float32, error) {
    31  	return []float32{}, nil
    32  }
    33  
    34  // MoveAwayFrom is not implemented in the NoOpVectorizer
    35  func (n *NoOpVectorizer) MoveAwayFrom(source []float32, target []float32, weight float32) ([]float32, error) {
    36  	return []float32{}, nil
    37  }
    38  
    39  // NormalizedDistance is not implemented in the NoOpVectorizer
    40  func (n *NoOpVectorizer) NormalizedDistance(a, b []float32) (float32, error) {
    41  	return 0, nil
    42  }
    43  
    44  // Object is not implemented in the NoOpVectorizer
    45  func (n *NoOpVectorizer) Object(ctx context.Context, concept *models.Object) ([]float32, error) {
    46  	return []float32{}, nil
    47  }
    48  
    49  // NewNoOp creates a new NoOpVectorizer which can be used when no vectorization
    50  // is desired, i.e. the feature is turned off completely
    51  func NewNoOp() *NoOpVectorizer {
    52  	return &NoOpVectorizer{}
    53  }