UNPKG

@accounter/server

Version:
43 lines (42 loc) 1.17 kB
/** * Overall Confidence Calculator * * Combines individual confidence scores (amount, currency, business, date) * into a single weighted overall confidence score. * * Formula: (amount × 0.4) + (currency × 0.2) + (business × 0.3) + (date × 0.1) */ export interface ConfidenceComponents { amount: number; currency: number; business: number; date: number; } /** * Calculate overall confidence score from individual components * * @param components - Individual confidence scores (each 0.0 to 1.0) * @returns Weighted overall confidence score (0.0 to 1.0, rounded to 2 decimals) * * @throws {Error} If any component is null or undefined * @throws {Error} If any component is outside the valid range [0.0, 1.0] * * @example * // Perfect match * calculateOverallConfidence({ * amount: 1.0, * currency: 1.0, * business: 1.0, * date: 1.0 * }) // Returns 1.0 * * @example * // Mixed confidence * calculateOverallConfidence({ * amount: 0.9, * currency: 1.0, * business: 0.5, * date: 0.8 * }) // Returns 0.79 */ export declare function calculateOverallConfidence(components: ConfidenceComponents): number;