<?php

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

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

// Check if Aliyun API returns bbox information for questions
$imagePath = storage_path('app/public/ocr-uploads/zlYK4F1eRX0lIQ2MA3ucCBMPEJk0UUvgvXEQgPYX.jpg');
$driver = app(\App\Services\OCR\Drivers\AliyunOCRDriver::class);

echo "Testing Aliyun API response structure...\n\n";

$result = $driver->recognize($imagePath, ['cutType' => 'answer']);

if (isset($result['questions']) && count($result['questions']) > 0) {
    $firstQuestion = $result['questions'][0];
    
    echo "First question structure:\n";
    echo "Keys: " . implode(', ', array_keys($firstQuestion)) . "\n\n";
    
    if (isset($firstQuestion['raw_data'])) {
        $rawData = $firstQuestion['raw_data'];
        echo "Raw data keys: " . implode(', ', array_keys($rawData)) . "\n\n";
        
        // Check for position information
        if (isset($rawData['content_list_info'])) {
            echo "Content list info found!\n";
            print_r($rawData['content_list_info']);
        }
        
        if (isset($rawData['pos'])) {
            echo "Position info found!\n";
            print_r($rawData['pos']);
        }
    }
} else {
    echo "No questions found in response\n";
}
