@tania6303/text-standardization
v1.2.0
Published
Text standardization utilities for Azure OCR - removes invisible characters, normalizes whitespace, line breaks, hyphens, and Hebrew punctuation
Maintainers
Readme
@tania6303/text-standardization
פונקציות ניקוי וסטנדרטיזציה של טקסט מ-Azure OCR / Form Recognizer.
התקנה
npm install @tania6303/text-standardizationשימוש בסיסי
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"פונקציות זמינות
standardizeText(text, options)
הפונקציה הראשית - מנקה את הכל.
אופציות:
{
removeInvisibleChars: true, // הסרת תווים בלתי נראים
normalizeWhitespace: true, // נרמול רווחים
normalizeLineBreaks: true, // נרמול שורות חדשות
normalizeHyphens: true, // נרמול מקפים
removeExtraSpaces: true, // הסרת רווחים מיותרים
fixVehicleNumbers: true, // תיקון מספרי רכב (XXX-XX-XXX)
fixNumbers: true, // תיקון מספרים עם רווחים
normalizeHebrew: true // נרמול תווים עבריים
}quickClean(text)
ניקוי מהיר - רק הבסיס (תווים בלתי נראים, רווחים, line breaks).
deepClean(text)
ניקוי מלא - כל האופציות מופעלות.
cleanForVehicles(text)
ניקוי ייעודי למספרי רכב ישראליים.
דוגמאות שימוש
שימוש ב-React/Vite
import { standardizeText } from '@tania6303/text-standardization';
function processInvoice(azureOcrResult) {
const cleanContent = standardizeText(azureOcrResult.content);
return cleanContent;
}שימוש עם Azure Form Recognizer
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" - ✅ תווי Unicode בעייתיים
רישיון
MIT
יוצר
Tania6303 [email protected]
