- Created setup scripts for advanced database, pricing database, and quote items. - Added a test script for OCR functionality, including PDF text extraction and price data extraction. - Included test files for various scenarios: poor categorization, material list, and text with noise.
36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
// Test script til at teste OCR funktionalitet direkte
|
|
const ocrService = require('./backend/src/services/ocrService');
|
|
const path = require('path');
|
|
|
|
async function testOCR() {
|
|
try {
|
|
console.log('Starting OCR test...');
|
|
|
|
const pdfPath = '/home/alex/git/tilbudgivern/frontend/tilbudspdf/Tilbud-1.pdf';
|
|
console.log('Testing with:', pdfPath);
|
|
|
|
// Test hvis filen eksisterer
|
|
const fs = require('fs');
|
|
if (!fs.existsSync(pdfPath)) {
|
|
console.error('PDF file not found:', pdfPath);
|
|
return;
|
|
}
|
|
|
|
console.log('PDF file exists, starting OCR...');
|
|
|
|
// Test OCR extraction
|
|
const ocrText = await ocrService.extractTextFromPDF(pdfPath);
|
|
console.log('OCR Text length:', ocrText.length);
|
|
console.log('OCR Text preview:', ocrText.substring(0, 200) + '...');
|
|
|
|
// Test price data extraction
|
|
const priceData = await ocrService.extractPriceDataFromText(ocrText, 'material');
|
|
console.log('Price data:', JSON.stringify(priceData, null, 2));
|
|
|
|
} catch (error) {
|
|
console.error('OCR test failed:', error);
|
|
}
|
|
}
|
|
|
|
testOCR();
|