classifier

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidFlagType = fmt.Errorf("not a valid FlagType, try [%s]", strings.Join(_FlagTypeNames, ", "))

Functions

func FlagTypeNames added in v0.8.0

func FlagTypeNames() []string

FlagTypeNames returns a list of possible string values of FlagType.

func Lists added in v0.8.0

func Lists() cel.EnvOption

Lists provides a CEL function library extension of list utility functions.

isSorted

Returns true if the provided list of comparable elements is sorted, else returns false.

<list<T>>.isSorted() <bool>, T must be a comparable type

Examples:

[1, 2, 3].isSorted()  // return true
['a', 'b', 'b', 'c'].isSorted()  // return true
[2.0, 1.0].isSorted()  // return false
[1].isSorted()  // return true
[].isSorted()  // return true

sum

Returns the sum of the elements of the provided list. Supports CEL number (int, uint, double) and duration types.

<list<T>>.sum() <T>, T must be a numeric type or a duration

Examples:

[1, 3].sum() // returns 4
[1.0, 3.0].sum() // returns 4.0
['1m', '1s'].sum() // returns '1m1s'
emptyIntList.sum() // returns 0
emptyDoubleList.sum() // returns 0.0
[].sum() // returns 0

min / max

Returns the minimum/maximum valued element of the provided list. Supports all comparable types. If the list is empty, an error is returned.

<list<T>>.min() <T>, T must be a comparable type
<list<T>>.max() <T>, T must be a comparable type

Examples:

[1, 3].min() // returns 1
[1, 3].max() // returns 3
[].min() // error
[1].min() // returns 1
([0] + emptyList).min() // returns 0

indexOf / lastIndexOf

Returns either the first or last positional index of the provided element in the list. If the element is not found, -1 is returned. Supports all equatable types.

<list<T>>.indexOf(<T>) <int>, T must be an equatable type
<list<T>>.lastIndexOf(<T>) <int>, T must be an equatable type

Examples:

[1, 2, 2, 3].indexOf(2) // returns 1
['a', 'b', 'b', 'c'].lastIndexOf('b') // returns 2
[1.0].indexOf(1.1) // returns -1
[].indexOf('string') // returns -1

Types

type Compiler added in v0.8.0

type Compiler interface {
	Compile(source Source) (Runner, error)
}

type Config added in v0.8.0

type Config struct {
	Workflow   string
	Keywords   map[string][]string
	Extensions map[string][]string
	Flags      map[string]any
	DeleteXxx  bool
}

func NewDefaultConfig added in v0.8.0

func NewDefaultConfig() Config

type FlagType added in v0.8.0

type FlagType string

FlagType represents the type of a flag ENUM(bool, string, int, string_list, content_type_list)

const (
	FlagTypeBool            FlagType = "bool"
	FlagTypeString          FlagType = "string"
	FlagTypeInt             FlagType = "int"
	FlagTypeStringList      FlagType = "string_list"
	FlagTypeContentTypeList FlagType = "content_type_list"
)

func FlagTypeValues added in v0.8.0

func FlagTypeValues() []FlagType

FlagTypeValues returns a list of the values for FlagType

func ParseFlagType added in v0.8.0

func ParseFlagType(name string) (FlagType, error)

ParseFlagType attempts to convert a string to a FlagType.

func (FlagType) IsValid added in v0.8.0

func (x FlagType) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (FlagType) MarshalText added in v0.8.0

func (x FlagType) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (*FlagType) Scan added in v0.8.0

func (x *FlagType) Scan(value interface{}) (err error)

Scan implements the Scanner interface.

func (FlagType) String added in v0.8.0

func (x FlagType) String() string

String implements the Stringer interface.

func (*FlagType) UnmarshalText added in v0.8.0

func (x *FlagType) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

func (FlagType) Value added in v0.8.0

func (x FlagType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Flags added in v0.9.0

type Flags map[string]any

type HasJsonSchema added in v0.8.0

type HasJsonSchema interface {
	JsonSchema() JsonSchema
}

type JsonSchema added in v0.8.0

type JsonSchema map[string]any

func DefaultJsonSchema added in v0.8.0

func DefaultJsonSchema() JsonSchema

func (JsonSchema) MarshalJSON added in v0.8.0

func (s JsonSchema) MarshalJSON() ([]byte, error)

type LocalSearch added in v0.8.0

type LocalSearch interface {
	ContentById(context.Context, model.ContentRef) (model.Content, error)
	ContentBySearch(context.Context, model.ContentType, string, model.Year) (model.Content, error)
}

type NullFlagType added in v0.8.0

type NullFlagType struct {
	FlagType FlagType
	Valid    bool
	Set      bool
}

func NewNullFlagType added in v0.8.0

func NewNullFlagType(val interface{}) (x NullFlagType)

func (NullFlagType) MarshalJSON added in v0.8.0

func (n NullFlagType) MarshalJSON() ([]byte, error)

MarshalJSON correctly serializes a NullFlagType to JSON.

func (*NullFlagType) Scan added in v0.8.0

func (x *NullFlagType) Scan(value interface{}) (err error)

Scan implements the Scanner interface.

func (*NullFlagType) UnmarshalJSON added in v0.8.0

func (n *NullFlagType) UnmarshalJSON(b []byte) error

UnmarshalJSON correctly deserializes a NullFlagType from JSON.

func (NullFlagType) Value added in v0.8.0

func (x NullFlagType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Params

type Params struct {
	fx.In
	Config     Config
	TmdbConfig tmdb.Config
	Search     lazy.Lazy[search.Search]
	TmdbClient lazy.Lazy[tmdb.Client]
}

type PayloadTransformerFunc added in v0.8.0

type PayloadTransformerFunc[From any, To any] func(From, compilerContext) (To, error)

type Result

type Result struct {
	fx.Out
	Compiler lazy.Lazy[Compiler]
	Source   lazy.Lazy[Source]
	Runner   lazy.Lazy[Runner]
}

func New

func New(params Params) Result

type Runner added in v0.8.0

type Runner interface {
	Run(ctx context.Context, workflow string, flags Flags, t model.Torrent) (classification.Result, error)
}

type Source added in v0.8.0

type Source struct {
	Schema          string          `json:"$schema,omitempty" yaml:"$schema,omitempty"`
	Workflows       workflowSources `json:"workflows"`
	FlagDefinitions flagDefinitions `json:"flag_definitions"`
	Flags           Flags           `json:"flags"`
	Keywords        keywordGroups   `json:"keywords"`
	Extensions      extensionGroups `json:"extensions"`
}

type TypedPayload added in v0.8.0

type TypedPayload[T any] interface {
	HasJsonSchema
	Unmarshal(ctx compilerContext) (T, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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