A class that extends BaseTranslator to translate structured queries into functional filters.

Example

const functionalTranslator = new FunctionalTranslator();
const relevantDocuments = await functionalTranslator.getRelevantDocuments(
"Which movies are rated higher than 8.5?",
);

Hierarchy

Constructors

Properties

VisitComparisonOutput: FunctionFilter
VisitOperationOutput: FunctionFilter
VisitStructuredQueryOutput: {
    filter: FunctionFilter;
} | {
    [k: string]: never;
}

Type declaration

Type declaration

  • [k: string]: never
allowedComparators: Comparator[] = ...
allowedOperators: Operator[] = ...

Methods

  • Returns a function that performs a comparison based on the provided comparator.

    Type Parameters

    Parameters

    • comparator: Comparator

      The comparator to base the comparison function on.

    Returns ((a, b) => boolean)

    A function that takes two arguments and returns a boolean based on the comparison.

      • (a, b): boolean
      • Returns a function that performs a comparison based on the provided comparator.

        Parameters

        • a: string | number
        • b: ValueType[C]

        Returns boolean

        A function that takes two arguments and returns a boolean based on the comparison.

  • Returns a function that performs an operation based on the provided operator.

    Parameters

    • operator: Operator

      The operator to base the operation function on.

    Returns ((a, b) => boolean)

    A function that takes two boolean arguments and returns a boolean based on the operation.

      • (a, b): boolean
      • Returns a function that performs an operation based on the provided operator.

        Parameters

        • a: boolean
        • b: boolean

        Returns boolean

        A function that takes two boolean arguments and returns a boolean based on the operation.

Generated using TypeDoc