Text standardization utilities for Azure OCR - removes invisible characters, normalizes whitespace, line breaks, hyphens, and Hebrew punctuation
npm install @tania6303/text-standardizationפונקציות ניקוי וסטנדרטיזציה של טקסט מ-Azure OCR / Form Recognizer.
``bash`
npm install @tania6303/text-standardization
`javascript
const { standardizeText } = require('@tania6303/text-standardization');
// דוגמה 1: ניקוי בסיסי
const dirtyText = "741 - 69 - 103 טיפול 75000 ק\"מ";
const cleanText = standardizeText(dirtyText);
console.log(cleanText); // "741-69-103 טיפול 75000 ק\"מ"
// דוגמה 2: טקסט עם תווים בלתי נראים
const azureText = "רכב\u200B459\u00A0-\u00A006\u00A0-\u00A0303";
const clean = standardizeText(azureText);
console.log(clean); // "רכב 459-06-303"
`
אופציות:
`javascript`
{
removeInvisibleChars: true, // הסרת תווים בלתי נראים
normalizeWhitespace: true, // נרמול רווחים
normalizeLineBreaks: true, // נרמול שורות חדשות
normalizeHyphens: true, // נרמול מקפים
removeExtraSpaces: true, // הסרת רווחים מיותרים
fixVehicleNumbers: true, // תיקון מספרי רכב (XXX-XX-XXX)
fixNumbers: true, // תיקון מספרים עם רווחים
normalizeHebrew: true // נרמול תווים עבריים
}
javascript
import { standardizeText } from '@tania6303/text-standardization';function processInvoice(azureOcrResult) {
const cleanContent = standardizeText(azureOcrResult.content);
return cleanContent;
}
`$3
`javascript
const { standardizeText } = require('@tania6303/text-standardization');async function processDocument(documentUrl) {
const result = await azureFormRecognizer.analyze(documentUrl);
const cleanText = standardizeText(result.content);
return cleanText;
}
`מה הפונקציה מנקה?
- ✅ תווים בלתי נראים:
\u200B, \u00A0, \uFEFF
- ✅ רווחים מיותרים: "741 - 69" → "741-69"
- ✅ מקפים שונים: en-dash (–), em-dash (—) → -
- ✅ line breaks מסוגים שונים (Windows/Mac/Unix)
- ✅ מספרי רכב: "459 - 06 - 303" → "459-06-303"
- ✅ מספרים: "75 000" → "75000"`MIT
Tania6303