core

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DocumentTextTitleIndex is the default Index of a Text representing
	// a Document's title.
	DocumentTextTitleIndex = 0
	// DocumentTextBodyIndex is the default Index of a Text representing
	// a Document's body.
	DocumentTextBodyIndex = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClassificationHit

type ClassificationHit struct {
	Tag   string
	Score float32
}

ClassificationHit is a single result from the Core.Classify function.

type Core

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

Core implements all main functionalities.

func New

func New(conf config.Config) (*Core, error)

New returns a new Core. Once done you should call Core.Finalize.

func (*Core) Classify

func (c *Core) Classify(
	ctx context.Context,
	namespaceName string,
	queryText string,
	size int,
) ([]ClassificationHit, error)

Classify performs a normal similarity/semantic over the set of Documents from a Namespace, then uses the tags from the document results to classify the input text.

func (*Core) Consolidate

func (c *Core) Consolidate(ctx context.Context, namespaceName string) error

Consolidate (re)builds the HNSW index from the current set of documents from the given namespace.

func (*Core) CreateNamespace

func (c *Core) CreateNamespace(ctx context.Context, name string) (*models.Namespace, error)

CreateNamespace creates a new Namespace.

func (*Core) DeleteDocument

func (c *Core) DeleteDocument(ctx context.Context, namespaceName string, id string) error

DeleteDocument deletes a document from a Namespace.

func (*Core) DeleteNamespace

func (c *Core) DeleteNamespace(ctx context.Context, name string) error

DeleteNamespace deletes a Namespace.

func (*Core) Finalize

func (c *Core) Finalize() error

Finalize frees various resources anc closes connections.

func (*Core) GetDocument

func (c *Core) GetDocument(ctx context.Context, namespaceName string, id string) (*models.Document, error)

GetDocument returns one Document from a Namespace.

func (*Core) GetDocuments

func (c *Core) GetDocuments(ctx context.Context, namespaceName string, first int, after string) ([]models.Document, error)

GetDocuments returns all Documents from a Namespace.

func (*Core) GetNamespace

func (c *Core) GetNamespace(ctx context.Context, name string) (*models.Namespace, error)

GetNamespace returns a Namespace by name.

func (*Core) GetNamespaces

func (c *Core) GetNamespaces(ctx context.Context) ([]models.Namespace, error)

GetNamespaces returns all Namespaces.

func (*Core) InsertDocuments

func (c *Core) InsertDocuments(ctx context.Context, docs []models.Document) error

InsertDocuments augments the given Documents' Texts with Tags and inserts the documents in the database.

func (*Core) Search

func (c *Core) Search(
	ctx context.Context,
	namespaceName string,
	queryText string,
	offset int,
	size int,
) ([]SearchHit, error)

Search performs a similarity/semantic search over the set of Documents from a Namespace.

type SearchHit

type SearchHit struct {
	Document        models.Document
	Score           float32
	TextsHighlights [][]TextHighlight
}

SearchHit is a single result from the Core.Search function.

type TextHighlight

type TextHighlight struct {
	Start     int
	End       int
	Text      string
	Relevance float32
}

TextHighlight is a single highlighted token from a Document's Text.

Jump to

Keyboard shortcuts

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