A production-ready skill for intelligent entity resolution across business domains. It combines exact-match and vector-semantic retrieval, OCR field mapping with confidence coloring, and human-in-the-loop verification with active learning.
javascript
import mdm from './index.js';
// 1. Get supported domains
mdm.getSupportedDomains(); // ['procurement', 'finance', 'sales', 'hr']
// 2. Build OCR-to-schema mapping with confidence colors
const mapping = mdm.buildOcrSchemaMapping(ocrFields, 'procurement');
// 3. Run full matching pipeline
const result = mdm.runMatchingPipeline(ocrEntity, 'procurement', dbRecords);
// 4. Format result as summary
console.log(mdm.formatMatchingSummary(result));
Four isolated schemas:
buildOcrSchemaMapping(ocrFields, domain) maps raw OCR field names to schema fields with confidence colors:
ColorScoreMeaning🟢 green≥ 0.92High confidence mapping🟡 yellow0.70–0.92Medium confidence mapping🔴 red< 0.70Low confidence / unmapped🔵 bluedb-onlyDatabase field, no OCR data
dualPathEntityRetrieval(entity, domain, dbRecords) runs two parallel paths:
Results include needsHumanReview: true if confidence < 0.92 or no match found.
verifyFieldValues(ocrEntity, dbRecord, domain) returns 4-state verification per field:
StateMeaningmatchOCR and DB values agreemismatchValues differ (requires human resolution)new_infoField only in OCR (new information)db_onlyField only in DB (not in OCR document)
Every pipeline result generates a hitlRequest with:
Use processHumanDecision(decision, state) to process human feedback and generate learning payloads.
updateActiveLearning(payloads, stats) tracks:
javascript
import mdm from './index.js';
// Sample OCR entity from a vendor invoice
const ocrVendor = {
vendor_name: 'Acme Corporation Ltd',
vendor_code: 'V-5001',
tax_id: '91110000123456789X',
contact_person: 'John Smith',
email: 'john.smith@acme.com',
};
// Existing database records
const dbRecords = [
{
id: 'rec_001',
vendor_name: 'Acme Corporation Ltd',
vendor_code: 'V-5001',
tax_id: '91110000123456789X',
contact_person: 'John Smith',
email: 'j.smith@acme.com', // slight email mismatch
phone: '+86-10-12345678',
address: 'Beijing Chaoyang District',
bank_account: '6222021234567890',
},
];
// Run pipeline
const result = mdm.runMatchingPipeline(ocrVendor, 'procurement', dbRecords);
console.log(mdm.formatMatchingSummary(result));
// Process human decision
const decision = { action: 'confirm_match', notes: 'Email mismatch acceptable' };
const { status, learningPayload } = mdm.processHumanDecision(decision, {
domain: 'procurement',
ocrEntity: ocrVendor,
matchResult: result.matchResult,
});
// Update active learning
const newStats = mdm.updateActiveLearning([learningPayload], {});
FunctionDescriptiongetSupportedDomains()List all supported business domainsgetDomainSchema(domain)Get field schema for a domainbuildOcrSchemaMapping(ocr, dom)Map OCR fields to schema with confidencedualPathEntityRetrieval(...)Run exact + semantic matchingverifyFieldValues(...)4-state field verificationrunMatchingPipeline(...)Full orchestration pipelinegenerateHitlReviewRequest(...)Build human review request payloadprocessHumanDecision(...)Handle human feedbackupdateActiveLearning(...)Update learning stats from decisionsformatMatchingSummary(...)Human-readable result summary