/** * Structured Government Data Extractor (INT-012) * * Extracts structured data from unstructured government portal pages. * Uses language-aware extraction combined with field-specific extraction patterns * to produce normalized government data: fees, requirements, timelines, documents. * * @example * ```typescript * import { StructuredGovDataExtractor } from 'llm-browser/sdk'; * * const extractor = new StructuredGovDataExtractor(); * * // Extract government data from HTML * const result = extractor.extract(html, { * contentType: 'requirements', * language: 'es', * }); * * // Validate against schema * const validation = extractor.validate(result); * if (!validation.valid) { * console.log('Validation errors:', validation.errors); * } * ``` */ import { type LanguageDetectionResult } from './language-aware-extraction.js'; /** * Content types for government data extraction */ export type GovContentType = 'requirements' | 'documents' | 'fees' | 'timeline' | 'forms' | 'contact' | 'appointment' | 'eligibility' | 'general'; /** * A monetary value with currency */ export interface MonetaryValue { /** The numeric amount */ amount: number; /** Currency code (ISO 4217) */ currency: string; /** Original text representation */ original: string; } /** * A date/timeline value */ export interface TimelineValue { /** Duration in days (if applicable) */ durationDays?: number; /** Duration description (e.g., "2-3 weeks") */ durationText?: string; /** Specific date if mentioned */ specificDate?: string; /** Original text */ original: string; } /** * A document requirement */ export interface DocumentRequirement { /** Document name */ name: string; /** Description or details */ description?: string; /** Whether the document is required vs optional */ required: boolean; /** Special notes about the document */ notes?: string; /** Related form number if applicable */ formNumber?: string; } /** * An eligibility requirement */ export interface EligibilityRequirement { /** Requirement description */ description: string; /** Category of requirement */ category?: 'age' | 'income' | 'residency' | 'employment' | 'other'; /** Whether this is mandatory */ mandatory: boolean; /** Additional notes */ notes?: string; } /** * A fee entry */ export interface FeeEntry { /** Fee description */ description: string; /** The fee amount and currency */ amount: MonetaryValue; /** Payment methods accepted */ paymentMethods?: string[]; /** Related form number (e.g., "modelo 790") */ formNumber?: string; /** Notes about this fee */ notes?: string; } /** * A timeline/processing step */ export interface ProcessingStep { /** Step name or description */ name: string; /** Estimated duration */ duration?: TimelineValue; /** Step order (1-based) */ order?: number; /** Notes about this step */ notes?: string; } /** * Contact information */ export interface ContactInfo { /** Department or office name */ name?: string; /** Phone number(s) */ phone?: string[]; /** Email address(es) */ email?: string[]; /** Physical address */ address?: string; /** Website URL */ website?: string; /** Office hours */ hours?: string; /** Notes */ notes?: string; } /** * Appointment/booking information */ export interface AppointmentInfo { /** Whether appointment is required */ required: boolean; /** Booking system URL */ bookingUrl?: string; /** Booking system name (e.g., "cita previa") */ systemName?: string; /** Available locations */ locations?: string[]; /** Tips for booking */ tips?: string[]; /** Notes */ notes?: string; } /** * Form information */ export interface FormInfo { /** Form identifier/number */ formNumber: string; /** Form name */ name?: string; /** Description of what it's for */ description?: string; /** Download URL */ downloadUrl?: string; /** Online submission URL */ onlineUrl?: string; /** Notes */ notes?: string; } /** * Complete structured government data */ export interface StructuredGovData { /** Data type that was extracted */ contentType: GovContentType; /** Detected language */ language: string; /** Language detection details */ languageDetection?: LanguageDetectionResult; /** Extraction confidence (0-1) */ confidence: number; /** Requirements and eligibility criteria */ requirements?: EligibilityRequirement[]; /** Required documents */ documents?: DocumentRequirement[]; /** Fees and costs */ fees?: FeeEntry[]; /** Processing timeline and steps */ timeline?: ProcessingStep[]; /** Forms to fill out */ forms?: FormInfo[]; /** Contact information */ contact?: ContactInfo; /** Appointment/booking information */ appointment?: AppointmentInfo; /** Raw extracted text (for context) */ rawText?: string; /** Extraction warnings */ warnings?: string[]; /** Source URL if known */ sourceUrl?: string; } /** * Extraction options */ export interface ExtractionOptions { /** Type of content to extract */ contentType?: GovContentType; /** Known language (skips detection if provided) */ language?: string; /** Source URL for context */ url?: string; /** Include raw text in output */ includeRawText?: boolean; /** Minimum confidence threshold (0-1) */ minConfidence?: number; } /** * Validation result */ export interface ValidationResult { /** Whether validation passed */ valid: boolean; /** Validation errors */ errors: ValidationError[]; /** Validation warnings */ warnings: ValidationWarning[]; } /** * Validation error */ export interface ValidationError { /** Field path that failed */ path: string; /** Error message */ message: string; /** Expected value/type */ expected?: string; /** Actual value/type */ actual?: string; } /** * Validation warning */ export interface ValidationWarning { /** Field path */ path: string; /** Warning message */ message: string; } /** * Extracts structured data from government portal HTML */ export declare class StructuredGovDataExtractor { private defaultCurrency; /** * Set the default currency for fee extraction */ setDefaultCurrency(currency: string): void; /** * Extract structured government data from HTML content */ extract(html: string, options?: ExtractionOptions): StructuredGovData; /** * Validate extracted data against expected schema */ validate(data: StructuredGovData): ValidationResult; /** * Extract requirements/eligibility from text */ private extractRequirements; /** * Add a requirement to the list with proper categorization */ private addRequirement; /** * Extract document requirements from text */ private extractDocuments; /** * Extract fees from text */ private extractFees; /** * Extract timeline/processing steps from text */ private extractTimeline; /** * Extract form information from text */ private extractForms; /** * Extract contact information from text */ private extractContact; /** * Extract appointment/booking information from text */ private extractAppointment; /** * Extract a monetary value from text */ private extractMonetaryValue; /** * Parse a duration string to days */ private parseDuration; } /** * Create a new StructuredGovDataExtractor */ export declare function createGovDataExtractor(): StructuredGovDataExtractor; /** * Extract structured government data from HTML */ export declare function extractGovData(html: string, options?: ExtractionOptions): StructuredGovData; /** * Validate structured government data */ export declare function validateGovData(data: StructuredGovData): ValidationResult; //# sourceMappingURL=structured-gov-data-extractor.d.ts.map