preferredOrder($domain, $identifier); } } return [ 'framework_profiles' => $this->frameworkProfiles(), 'domain_definitions' => $this->domainDefinitions(), 'reference_descriptors' => $this->referenceDescriptors(), 'preferred_orders' => $preferred, 'media_providers' => ['MusicBrainz', 'Wikidata'], 'generic_providers' => ['GS1', 'OpenFoodFacts'], 'field_confidence_profiles' => [ 'GoogleBooks' => [ 'priority' => 1000, 'requires_api_key' => false, 'fields' => [ 'isbn' => 0.95, 'images' => 0.85, 'description' => 0.90, 'authors' => 0.95, 'publisher' => 0.90, 'categories' => 0.80, 'language' => 0.95, 'page_count' => 0.85, 'publication_date' => 0.90, 'series' => 0.45, 'subjects' => 0.70, ], ], 'OpenLibrary' => [ 'priority' => 900, 'requires_api_key' => false, 'fields' => [ 'isbn' => 0.95, 'images' => 0.90, 'description' => 0.85, 'authors' => 0.90, 'publisher' => 0.85, 'categories' => 0.90, 'language' => 0.85, 'page_count' => 0.80, 'publication_date' => 0.85, 'series' => 0.75, 'subjects' => 0.95, ], ], 'InternetArchive' => [ 'priority' => 800, 'requires_api_key' => false, 'fields' => [ 'isbn' => 0.80, 'images' => 0.60, 'description' => 0.75, 'authors' => 0.75, 'publisher' => 0.75, 'categories' => 0.80, 'language' => 0.80, 'page_count' => 0.45, 'publication_date' => 0.75, 'series' => 0.55, 'subjects' => 0.90, ], ], 'WorldCat' => [ 'priority' => 700, 'requires_api_key' => true, 'fields' => [ 'isbn' => 0.98, 'images' => 0.25, 'description' => 0.65, 'authors' => 0.95, 'publisher' => 0.95, 'categories' => 0.85, 'language' => 0.90, 'page_count' => 0.85, 'publication_date' => 0.95, 'series' => 0.90, 'subjects' => 0.95, ], ], 'ISBNdb' => [ 'priority' => 600, 'requires_api_key' => true, 'fields' => [ 'isbn' => 0.98, 'images' => 0.70, 'description' => 0.85, 'authors' => 0.90, 'publisher' => 0.90, 'categories' => 0.75, 'language' => 0.90, 'page_count' => 0.75, 'publication_date' => 0.90, 'series' => 0.75, 'subjects' => 0.75, ], ], ], 'update_evidence_adapters' => [\TFGraphics\SmartImport\Providers\Wikidata\WikidataUpdatePreserver::class], ]; } public function domainDefinitions(): array { $definitions = []; $bookIdentifiers = [DomainIdentifier::ISBN10, DomainIdentifier::ISBN13, DomainIdentifier::EAN, DomainIdentifier::TITLE]; $mediaIdentifiers = [DomainIdentifier::EAN, DomainIdentifier::UPC, DomainIdentifier::GTIN, DomainIdentifier::BARCODE, DomainIdentifier::TITLE]; $productIdentifiers = [DomainIdentifier::EAN, DomainIdentifier::UPC, DomainIdentifier::GTIN, DomainIdentifier::BARCODE, DomainIdentifier::TITLE]; $definitions[] = ['GoogleBooks', [DomainRegistry::BOOKS], $bookIdentifiers, 100, 0.98]; $definitions[] = ['OpenLibrary', [DomainRegistry::BOOKS], $bookIdentifiers, 90, 0.95]; $definitions[] = ['InternetArchive', [DomainRegistry::BOOKS], $bookIdentifiers, 80, 0.90]; $definitions[] = ['Wikidata', [DomainRegistry::MOVIES], [DomainIdentifier::TITLE], 100, 0.90]; $definitions[] = ['MusicBrainz', [DomainRegistry::MUSIC], $mediaIdentifiers, 100, 0.97]; $definitions[] = ['OpenFoodFacts', [DomainRegistry::FOOD], $productIdentifiers, 100, 0.94]; return $definitions; } public function frameworkProfiles(): array { $bookIds = [DomainIdentifier::ISBN10, DomainIdentifier::ISBN13, DomainIdentifier::EAN13, DomainIdentifier::TITLE]; $mediaIds = [DomainIdentifier::EAN8, DomainIdentifier::EAN13, DomainIdentifier::UPC_A, DomainIdentifier::GTIN, DomainIdentifier::TITLE]; $genericIds = [DomainIdentifier::EAN8, DomainIdentifier::EAN13, DomainIdentifier::UPC_A, DomainIdentifier::GTIN, DomainIdentifier::TITLE]; return [ $this->profile('Google Books', [ProductDomainRegistry::BOOKS], $bookIds, 100, [0.95, 0.90, 0.72, 0.88, 0.72, 0.78, 0.25], [0.90, 0.90, 0.72, 0.82, 0.92, 0.78], [ 'commercial' => true, 'persistence' => false, 'languages' => ['*'], 'countries' => ['*'], 'caching' => 'temporary caching only', 'authentication' => 'optional API key', 'limitations' => ['Google API terms restrict long-term persistence'], ]), $this->profile('OpenLibrary', [ProductDomainRegistry::BOOKS], $bookIds, 95, [0.90, 0.76, 0.90, 0.85, 0.82, 0.92, 0.20], [0.88, 0.90, 0.76, 0.90, 0.88, 0.90], [ 'commercial' => true, 'persistence' => true, 'attribution' => true, 'license' => 'Open Library data terms', 'persistence_policy' => 'allowed with attribution', ]), $this->profile('Internet Archive', [ProductDomainRegistry::BOOKS], array_values(array_unique(array_merge($mediaIds, [DomainIdentifier::ISBN10, DomainIdentifier::ISBN13]))), 82, [0.78, 0.65, 0.60, 0.74, 0.68, 0.82, 0.10], [0.76, 0.78, 0.65, 0.65, 0.80, 0.72], [ 'commercial' => true, 'persistence' => true, 'attribution' => true, 'license' => 'Item-specific metadata terms', 'persistence_policy' => 'metadata persistence allowed; item rights vary', ]), $this->profile('Wikidata', [ProductDomainRegistry::MOVIES], [DomainIdentifier::TITLE], 84, [0.80, 0.68, 0.70, 0.76, 0.72, 0.65, 0.15], [0.76, 0.80, 0.68, 0.70, 0.82, 0.60], [ 'authentication' => 'none', 'commercial' => true, 'persistence' => true, 'license' => 'CC0 (metadata); file-specific Commons images', ]), $this->profile('MusicBrainz', [ProductDomainRegistry::MUSIC], $mediaIds, 96, [0.96, 0.60, 0.62, 0.55, 0.94, 0.90, 0.15], [0.92, 0.96, 0.60, 0.62, 0.94, 0.92], [ 'commercial' => true, 'persistence' => true, 'attribution' => true, 'license' => 'CC0 / CC BY-SA datasets', 'persistence_policy' => 'allowed according to dataset license', 'rate_limits' => ['requests_per_second' => 1], ]), $this->profile('OpenFoodFacts', [ProductDomainRegistry::FOOD], $genericIds, 92, [0.88, 0.42, 0.78, 0.62, 0.90, 0.90, 0.92], [0.90, 0.88, 0.42, 0.78, 0.86, 0.95], [ 'commercial' => true, 'persistence' => true, 'attribution' => true, 'license' => 'ODbL / database contents license', 'persistence_policy' => 'allowed with license compliance', ]), ]; } private function profile( string $name, array $domains, array $identifiers, int $priority, array $qualities, array $scores, array $overrides = [] ): array { $qualityKeys = ['metadata', 'seo', 'image', 'description', 'attributes', 'category', 'brand']; $scoreKeys = ['coverage', 'metadata', 'seo', 'media', 'reliability', 'commercial_suitability']; return array_replace([ 'name' => $name, 'domains' => $domains, 'identifiers' => $identifiers, 'priority' => $priority, 'quality' => array_combine($qualityKeys, $qualities), 'scores' => array_combine($scoreKeys, $scores), 'reliability' => $scores[4], 'speed' => 0.75, ], $overrides); } public function preferredOrder(string $domain, string $identifierType): array { if ($domain === DomainRegistry::BOOKS && in_array($identifierType, [DomainIdentifier::ISBN10, DomainIdentifier::ISBN13, DomainIdentifier::EAN13], true)) { return ['Google Books', 'OpenLibrary', 'Internet Archive']; } if ($domain === DomainRegistry::FOOD && in_array($identifierType, [DomainIdentifier::EAN8, DomainIdentifier::EAN13, DomainIdentifier::UPC_A, DomainIdentifier::GTIN], true)) { return ['OpenFoodFacts']; } if ($domain === DomainRegistry::MOVIES && $identifierType === DomainIdentifier::TITLE) { return ['Wikidata']; } return []; } public function referenceDescriptors(): array { return [ new ProviderDescriptor('GoogleBooks', 'Google Books', ['BOOKS'], ['supportsIdentifierSearch' => true, 'supportsTitleSearch' => true, 'supportsBarcodeSearch' => false, 'supportsImage' => true, 'supportsMetadata' => true, 'supportsPrice' => false, 'supportsDescription' => true], true, true, 'api_key', true, 1, null, [], true, true, 'commercial', true, true, false, true, true, false, true), new ProviderDescriptor('OpenLibrary', 'OpenLibrary', ['BOOKS'], ['supportsIdentifierSearch' => true, 'supportsTitleSearch' => true, 'supportsBarcodeSearch' => false, 'supportsImage' => true, 'supportsMetadata' => true, 'supportsPrice' => false, 'supportsDescription' => true], true, false, null, true, 2, null, [], true, true, 'commercial', true, true, false, true, true, false, true), new ProviderDescriptor('InternetArchive', 'Internet Archive', ['BOOKS', 'MUSIC', 'MOVIES'], ['supportsIdentifierSearch' => true, 'supportsTitleSearch' => true, 'supportsBarcodeSearch' => false, 'supportsImage' => true, 'supportsMetadata' => true, 'supportsPrice' => false, 'supportsDescription' => true], true, false, null, null, null, null, [], true, true, 'commercial', true, true, false, true, true, false, true), new ProviderDescriptor('ISBNdb', 'ISBNdb', ['BOOKS'], ['supportsIdentifierSearch' => true, 'supportsTitleSearch' => true, 'supportsBarcodeSearch' => false, 'supportsImage' => true, 'supportsMetadata' => true, 'supportsPrice' => false, 'supportsDescription' => true], true, true, 'api_key', false, 3, null, [], true, true, 'commercial', true, true, false, true, true, false, true), new ProviderDescriptor('WorldCat', 'WorldCat', ['BOOKS'], ['supportsIdentifierSearch' => true, 'supportsTitleSearch' => true, 'supportsBarcodeSearch' => false, 'supportsImage' => false, 'supportsMetadata' => true, 'supportsPrice' => false, 'supportsDescription' => true], true, true, 'api_key', false, 4, null, [], true, true, 'commercial', true, true, false, false, true, false, true), ]; } }