Spaces:
Running
Running
// _ _ | |
// __ _____ __ ___ ___ __ _| |_ ___ | |
// \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ | |
// \ V V / __/ (_| |\ V /| | (_| | || __/ | |
// \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| | |
// | |
// Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. | |
// | |
// CONTACT: [email protected] | |
// | |
package vectorizer | |
import ( | |
"github.com/weaviate/weaviate/entities/moduletools" | |
) | |
const ( | |
DefaultPropertyIndexed = true | |
DefaultVectorizeClassName = true | |
DefaultVectorizePropertyName = false | |
DefaultPoolingStrategy = "masked_mean" | |
) | |
type classSettings struct { | |
cfg moduletools.ClassConfig | |
} | |
func NewClassSettings(cfg moduletools.ClassConfig) *classSettings { | |
return &classSettings{cfg: cfg} | |
} | |
func (ic *classSettings) PropertyIndexed(propName string) bool { | |
if ic.cfg == nil { | |
// we would receive a nil-config on cross-class requests, such as Explore{} | |
return DefaultPropertyIndexed | |
} | |
vcn, ok := ic.cfg.Property(propName)["skip"] | |
if !ok { | |
return DefaultPropertyIndexed | |
} | |
asBool, ok := vcn.(bool) | |
if !ok { | |
return DefaultPropertyIndexed | |
} | |
return !asBool | |
} | |
func (ic *classSettings) VectorizePropertyName(propName string) bool { | |
if ic.cfg == nil { | |
// we would receive a nil-config on cross-class requests, such as Explore{} | |
return DefaultVectorizePropertyName | |
} | |
vcn, ok := ic.cfg.Property(propName)["vectorizePropertyName"] | |
if !ok { | |
return DefaultVectorizePropertyName | |
} | |
asBool, ok := vcn.(bool) | |
if !ok { | |
return DefaultVectorizePropertyName | |
} | |
return asBool | |
} | |
func (ic *classSettings) VectorizeClassName() bool { | |
if ic.cfg == nil { | |
// we would receive a nil-config on cross-class requests, such as Explore{} | |
return DefaultVectorizeClassName | |
} | |
vcn, ok := ic.cfg.Class()["vectorizeClassName"] | |
if !ok { | |
return DefaultVectorizeClassName | |
} | |
asBool, ok := vcn.(bool) | |
if !ok { | |
return DefaultVectorizeClassName | |
} | |
return asBool | |
} | |
func (ic *classSettings) PoolingStrategy() string { | |
if ic.cfg == nil { | |
// we would receive a nil-config on cross-class requests, such as Explore{} | |
return DefaultPoolingStrategy | |
} | |
vcn, ok := ic.cfg.Class()["poolingStrategy"] | |
if !ok { | |
return DefaultPoolingStrategy | |
} | |
asString, ok := vcn.(string) | |
if !ok { | |
return DefaultPoolingStrategy | |
} | |
return asString | |
} | |