import { DeepKeyOf } from '../lib/odata'; import { AnalyzedDocument, AnalyzedValue } from './analyzerService'; import { SchemaService } from './schema'; export interface ScoringFnIdentity { fieldName: DeepKeyOf; } export interface ScoringFnApplication { boost: number; interpolation?: 'constant' | 'linear' | 'quadratic' | 'logarithmic'; } export interface ScoringMagnitudeFn extends ScoringFnApplication { type: 'magnitude'; magnitude: { boostingRangeStart: number; boostingRangeEnd: number; constantBoostBeyondRange?: boolean; }; } export interface ScoringFreshnessFn extends ScoringFnApplication { type: 'freshness'; freshness: { boostingDuration: string; }; } export interface ScoringDistanceFn extends ScoringFnApplication { type: 'distance'; distance: { referencePointParameter: string; boostingDistance: number; }; } export interface ScoringTagFn extends ScoringFnApplication { type: 'tag'; tag: { tagsParameter: string; }; } export declare type ScoringFn = ScoringMagnitudeFn | ScoringFreshnessFn | ScoringDistanceFn | ScoringTagFn; export declare type IdentifiedScoringFn = ScoringFnIdentity & ScoringFn; export interface ScoringProfile { name: string; text?: { weights: Partial, number>>; }; functions?: IdentifiedScoringFn[]; functionAggregation?: 'sum' | 'average' | 'minimum' | 'maximum' | 'firstMatching'; } export declare type ScoringParams = Record; export declare type ScoringBases = { key: string; score: number; }[]; export declare type ScoringStrategy = (value: AnalyzedValue) => number; export declare type ScoringStrategies = (document: AnalyzedDocument, bases: ScoringBases) => number; export declare type RawScoringStrategy = (params: ScoringParams) => ScoringStrategy; export declare type RawScoringStrategies = (params: ScoringParams) => ScoringStrategies; export declare class Scorer { readonly schemaService: SchemaService; readonly profiles: ScoringProfile[]; readonly defaultProfile: string | null; strategies: Record; defaultStrategy: RawScoringStrategies | null; static readonly nullStrategy: ScoringStrategies; constructor(schemaService: SchemaService, profiles: ScoringProfile[], defaultProfile: string | null); getScoringStrategies(profile: string | null, parameters: string[] | null): ScoringStrategies; }