Skip to main content
Glama
josuekongolo

CompanyIQ MCP Server

by josuekongolo
test-tnok-fix.jsβ€’3.89 kB
import dotenv from 'dotenv'; dotenv.config(); import { OpenAIVisionParser } from './build/scraper/openai_vision_parser.js'; import { existsSync } from 'fs'; async function testTnokFix() { console.log('πŸ§ͺ Testing TNOK Unit Detection Fix'); console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'); const apiKey = process.env.OPENAI_API_KEY; if (!apiKey) { console.error('❌ OPENAI_API_KEY not found!'); process.exit(1); } const parser = new OpenAIVisionParser(apiKey); // Test with the problematic PDF mentioned const testPdf = 'data/pdfs/928102939/aarsregnskap_928102939-2023.pdf'; if (!existsSync(testPdf)) { console.log('⚠️ Test PDF not found, trying alternative...'); // Try any available PDF const alternatives = [ 'data/pdfs/984562861/aarsregnskap_984562861-2010.pdf', 'data/pdfs/999059198/aarsregnskap_999059198-2021.pdf', 'data/pdfs/temp/aarsregnskap_999059198-2021.pdf' ]; let found = false; for (const alt of alternatives) { if (existsSync(alt)) { console.log(`βœ… Using alternative: ${alt}`); await testPdf(parser, alt); found = true; break; } } if (!found) { console.error('❌ No test PDFs available'); process.exit(1); } } else { await testPdfExtraction(parser, testPdf); } } async function testPdfExtraction(parser, pdfPath) { console.log(`πŸ“„ Testing PDF: ${pdfPath}`); console.log('πŸ”„ Starting extraction (this may take 30-60 seconds)...\n'); try { const startTime = Date.now(); const result = await parser.parseFinancialPDF(pdfPath); const duration = Math.round((Date.now() - startTime) / 1000); console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'); console.log('πŸ“Š EXTRACTION RESULTS'); console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'); console.log(`⏱️ Time: ${duration} seconds\n`); // Check if values look reasonable (not 1000x too large) const checkValue = (name, value) => { if (value === null) { console.log(`${name}: Not found`); return; } const millions = value / 1000000; const billions = value / 1000000000; // Flag if value seems unreasonably large (> 100 billion NOK for small companies) if (billions > 100) { console.log(`${name}: ${billions.toFixed(1)}B NOK ⚠️ SEEMS TOO LARGE!`); console.log(` Raw value: ${value}`); console.log(` If TNOK, should be: ${(value/1000/1000000).toFixed(1)}M NOK`); } else if (billions > 1) { console.log(`${name}: ${billions.toFixed(1)}B NOK`); } else { console.log(`${name}: ${millions.toFixed(1)}M NOK βœ…`); } }; checkValue('πŸ’° Revenue', result.revenue); checkValue('πŸ“ˆ Profit', result.profit); checkValue('🏒 Assets', result.assets); checkValue('πŸ’Ž Equity', result.equity); // Analyze if values seem correct console.log('\nπŸ” Analysis:'); const hasLargeValues = [result.revenue, result.profit, result.assets, result.equity] .filter(v => v !== null && v > 100000000000); // > 100 billion if (hasLargeValues.length > 0) { console.log('❌ Some values appear to be 1000x too large!'); console.log(' This suggests TNOK values were incorrectly multiplied.'); } else { console.log('βœ… All values appear to be in the correct range!'); console.log(' TNOK handling seems to be working correctly.'); } } catch (error) { console.error('❌ Extraction failed:', error.message); console.error('\nThis might indicate an issue with the parser.'); } } testTnokFix();

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/josuekongolo/companyiq-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server