UNPKG

@kermank/nldp

Version:

A modular date/time parser for converting natural language into dates and times

42 lines 1.54 kB
import { DateTime } from 'luxon'; import { ParseMetadata } from '../types/types'; import { ParseTrace } from '../utils/debug-trace'; export type ComponentType = 'date' | 'time' | 'range' | 'modifier'; export interface ParseComponent { type: ComponentType; span: { start: number; end: number; }; confidence: number; value: DateTime | { start: DateTime; end: DateTime; }; debugTrace?: ParseTrace; metadata?: ParseMetadata; } /** * Sort components by: * 1. Span length (longer matches first) * 2. Confidence (higher confidence first) * 3. Position in text (earlier matches first) */ export declare const sortComponents: (components: ParseComponent[]) => ParseComponent[]; /** * Check if two components have overlapping spans in the original text */ export declare const hasOverlap: (a: ParseComponent, b: ParseComponent) => boolean; /** * Group components that can be combined together (non-overlapping spans and compatible types) */ export declare const groupCompatibleComponents: (components: ParseComponent[]) => ParseComponent[][]; /** * Resolve a group of compatible components into a final parse result */ export declare const resolveGroup: (components: ParseComponent[]) => ParseComponent | null; /** * Main resolution function that takes all parsed components and returns the best parse result */ export declare const resolveComponents: (components: ParseComponent[], inputText: string) => ParseComponent | null; //# sourceMappingURL=resolution-engine.d.ts.map