vectorizer

package
v1.26.0-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewIndexChecker

func NewIndexChecker(cfg moduletools.ClassConfig) *indexChecker

Types

type ClassIndexCheck

type ClassIndexCheck interface {
	PropertyIndexed(property string) bool
	VectorizeClassName() bool
	VectorizePropertyName(propertyName string) bool
}

IndexCheck returns whether a property of a class should be indexed

type ConfigValidator

type ConfigValidator struct {
	// contains filtered or unexported fields
}

func NewConfigValidator

func NewConfigValidator(rc RemoteClient,
	logger logrus.FieldLogger,
) *ConfigValidator

func (*ConfigValidator) Do

type ErrNoUsableWords

type ErrNoUsableWords struct {
	Err error
}

func NewErrNoUsableWordsf

func NewErrNoUsableWordsf(pattern string, args ...interface{}) ErrNoUsableWords

func (ErrNoUsableWords) Error

func (e ErrNoUsableWords) Error() string

type IndexChecker

type IndexChecker interface {
	VectorizeClassName() bool
	VectorizePropertyName(propName string) bool
	PropertyIndexed(propName string) bool
}

type Inspector

type Inspector struct {
	// contains filtered or unexported fields
}

func NewInspector

func NewInspector(client InspectorClient) *Inspector

func (*Inspector) GetWords

func (i *Inspector) GetWords(ctx context.Context, words string) (*models.C11yWordsResponse, error)

type InspectorClient

type InspectorClient interface {
	VectorForWord(ctx context.Context, word string) ([]float32, error)
	VectorForCorpi(ctx context.Context, words []string,
		overrides map[string]string) ([]float32, []txt2vecmodels.InterpretationSource, error)
	NearestWordsByVector(ctx context.Context, vector []float32, n int, k int) ([]string, []float32, error)
	IsWordPresent(ctx context.Context, word string) (bool, error)
}

type NoOpVectorizer

type NoOpVectorizer struct{}

NoOpVectorizer is a simple stand in that does nothing. Can be used when the feature should be turned off overall

func NewNoOp

func NewNoOp() *NoOpVectorizer

NewNoOp creates a new NoOpVectorizer which can be used when no vectorization is desired, i.e. the feature is turned off completely

func (*NoOpVectorizer) Corpi

func (n *NoOpVectorizer) Corpi(ctx context.Context, corpi []string) ([]float32, error)

Corpi is not implemented in the NoOpVectorizer

func (*NoOpVectorizer) MoveAwayFrom

func (n *NoOpVectorizer) MoveAwayFrom(source []float32, target []float32, weight float32) ([]float32, error)

MoveAwayFrom is not implemented in the NoOpVectorizer

func (*NoOpVectorizer) MoveTo

func (n *NoOpVectorizer) MoveTo(source []float32, target []float32, weight float32) ([]float32, error)

MoveTo is not implemented in the NoOpVectorizer

func (*NoOpVectorizer) NormalizedDistance

func (n *NoOpVectorizer) NormalizedDistance(a, b []float32) (float32, error)

NormalizedDistance is not implemented in the NoOpVectorizer

func (*NoOpVectorizer) Object

func (n *NoOpVectorizer) Object(ctx context.Context, concept *models.Object) ([]float32, error)

Object is not implemented in the NoOpVectorizer

type RemoteClient

type RemoteClient interface {
	IsStopWord(ctx context.Context, word string) (bool, error)
	IsWordPresent(ctx context.Context, word string) (bool, error)
}

type Vectorizer

type Vectorizer struct {
	// contains filtered or unexported fields
}

Vectorizer turns objects into vectors

func New

func New(client client) *Vectorizer

New from c11y client

func (*Vectorizer) Corpi

func (v *Vectorizer) Corpi(ctx context.Context, corpi []string,
) ([]float32, error)

Corpi takes any list of strings and builds a common vector for all of them

func (*Vectorizer) Object

Object object to vector

func (*Vectorizer) Texts added in v1.23.3

func (v *Vectorizer) Texts(ctx context.Context, inputs []string,
	cfg moduletools.ClassConfig,
) ([]float32, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL