Skip to main content

TrigramWordBase

This class represents a database function used to calculate the trigram similarity between a specific string and a given expression. It initializes with a string value and an expression, ensuring the input string is treated as a value if it does not already support expression resolution. The function typically returns a floating-point value representing the similarity score.

Attributes

AttributeTypeDescription
output_field[FloatField](../../../forms/fields/floatfield.md?sid=django_forms_fields_floatfield) = FloatField()Specifies that the result of the trigram function should be treated as a floating-point number.

Constructor

Signature

def TrigramWordBase(
string: Any,
expression: Any,
**extra: dict
)

Parameters

NameTypeDescription
stringAnyThe string to be evaluated, which is converted to a Value object if it lacks a resolve_expression method.
expressionAnyThe expression to compare against the string.
**extradictAdditional keyword arguments passed to the parent Func class.

Signature

def TrigramWordBase(
string: str | Expression,
expression: [Expression](../../../db/models/expressions/expression.md?sid=django_db_models_expressions_expression),
**extra: dict
) - > null

Parameters

NameTypeDescription
string`strExpression`
expression[Expression](../../../db/models/expressions/expression.md?sid=django_db_models_expressions_expression)The database column or expression against which the trigram similarity is calculated.
**extradictAdditional keyword arguments passed to the underlying Func class for configuring database function behavior.