<?php

require __DIR__.'/vendor/autoload.php';

$app = require_once __DIR__.'/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();

$imagePath = storage_path('app/public/ocr-uploads/zlYK4F1eRX0lIQ2MA3ucCBMPEJk0UUvgvXEQgPYX.jpg');
$driver = app(\App\Services\OCR\Drivers\AliyunOCRDriver::class);

echo "Testing Phase 1 (questions):\n";
$result1 = $driver->recognize($imagePath, ['cutType' => 'question']);
echo "Count: " . count($result1['questions']) . "\n";
if (!empty($result1['questions'])) {
    $first = $result1['questions'][0];
    echo "First Q number: " . $first['question_number'] . "\n";
    echo "First Q content length: " . strlen($first['content']) . "\n";
    echo "First Q content: " . substr($first['content'], 0, 100) . "\n";
}

echo "\nTesting Phase 2 (answers):\n";
$result2 = $driver->recognize($imagePath, ['cutType' => 'answer']);
echo "Count: " . count($result2['questions']) . "\n";
if (!empty($result2['questions'])) {
    $first = $result2['questions'][0];
    echo "First A number: " . $first['question_number'] . "\n";
    echo "First A content length: " . strlen($first['content']) . "\n";
    echo "First A content: " . substr($first['content'], 0, 100) . "\n";
}
