rules = $rules ?? new DomainRules($this->getDefaultDefinitions()); } public function getRules(): DomainRules { return $this->rules; } private function getDefaultDefinitions(): array { return [ $this->rule(DomainRegistry::BOOKS, 'identifier', [DomainIdentifier::ISBN10, DomainIdentifier::ISBN13, DomainIdentifier::ISSN], 0.98, 'Identifier is specific to books or serial publications.'), $this->rule(DomainRegistry::BOOKS, 'keyword', ['book', 'novel', 'paperback', 'hardcover', 'harry potter'], 0.34, 'Book vocabulary matched.'), $this->rule(DomainRegistry::BOOKS, 'pattern', ['harry potter', 'isbn'], 0.60, 'Known publication pattern matched.'), $this->rule(DomainRegistry::MOVIES, 'keyword', ['movie', 'film', 'dvd', 'blu-ray', 'bluray'], 0.34, 'Movie format vocabulary matched.'), $this->rule(DomainRegistry::MOVIES, 'pattern', ['blu-ray', 'bluray', '4k uhd'], 0.60, 'Known home-video product pattern matched.'), $this->rule(DomainRegistry::GAMES, 'keyword', ['switch', 'playstation', 'xbox', 'video game', 'videogame'], 0.34, 'Gaming vocabulary matched.'), $this->rule(DomainRegistry::GAMES, 'brand', ['nintendo', 'playstation', 'xbox'], 0.32, 'Known gaming brand matched.'), $this->rule(DomainRegistry::GAMES, 'pattern', ['nintendo switch', 'switch oled', 'playstation 5', 'ps5'], 0.28, 'Known console product pattern matched.'), $this->rule(DomainRegistry::MUSIC, 'keyword', ['cd ', 'album', 'vinyl', 'record', 'soundtrack'], 0.34, 'Music format vocabulary matched.'), $this->rule(DomainRegistry::MUSIC, 'brand', ['pink floyd'], 0.32, 'Known music artist signal matched.'), $this->rule(DomainRegistry::MUSIC, 'pattern', ['pink floyd'], 0.28, 'Known artist pattern matched.'), $this->rule(DomainRegistry::MUSIC, 'pattern', ['012569'], 0.92, 'Known music catalog prefix matched.'), $this->rule(DomainRegistry::INDUSTRIAL, 'brand', ['bosch', 'makita', 'dewalt'], 0.32, 'Known industrial tool brand matched.'), $this->rule(DomainRegistry::INDUSTRIAL, 'manufacturer', ['bosch', 'makita', 'dewalt'], 0.32, 'Known industrial manufacturer matched.'), $this->rule(DomainRegistry::INDUSTRIAL, 'category', ['power tools', 'industrial tools'], 0.34, 'Industrial category hint matched.'), $this->rule(DomainRegistry::INDUSTRIAL, 'pattern', ['gsb 18v', 'gbl 18v', 'cordless drill'], 0.62, 'Known industrial tool model pattern matched.'), $this->rule(DomainRegistry::ELECTRONICS, 'brand', ['bosch', 'sony', 'samsung', 'apple'], 0.28, 'Known electronics brand matched.'), $this->rule(DomainRegistry::ELECTRONICS, 'category', ['electronics', 'consumer electronics'], 0.34, 'Electronics category hint matched.'), $this->rule(DomainRegistry::ELECTRONICS, 'pattern', ['18v', 'oled', 'smartphone', 'laptop'], 0.45, 'Known electronics product pattern matched.'), $this->rule(DomainRegistry::COLLECTIBLES, 'brand', ['lego'], 0.32, 'Known collectible brand matched.'), $this->rule(DomainRegistry::COLLECTIBLES, 'keyword', ['technic', 'collectible', 'memorabilia'], 0.34, 'Collectibles vocabulary matched.'), $this->rule(DomainRegistry::COLLECTIBLES, 'pattern', ['lego technic', 'trading card'], 0.28, 'Known collectible product pattern matched.'), $this->rule(DomainRegistry::TOYS, 'brand', ['lego', 'hasbro', 'mattel'], 0.28, 'Known toy brand matched.'), $this->rule(DomainRegistry::TOYS, 'category', ['toys', 'building toys'], 0.34, 'Toy category hint matched.'), $this->rule(DomainRegistry::TOYS, 'pattern', ['lego technic', 'building set'], 0.42, 'Known toy product pattern matched.'), $this->rule(DomainRegistry::FOOD, 'brand', ['barilla', 'nestle', 'kelloggs'], 0.32, 'Known food brand matched.'), $this->rule(DomainRegistry::FOOD, 'manufacturer', ['barilla', 'nestle', 'kelloggs'], 0.32, 'Known food manufacturer matched.'), $this->rule(DomainRegistry::FOOD, 'keyword', ['spaghetti', 'pasta', 'food', 'beverage'], 0.34, 'Food vocabulary matched.'), $this->rule(DomainRegistry::FOOD, 'category', ['food', 'grocery', 'pasta'], 0.34, 'Food category hint matched.'), $this->rule(DomainRegistry::FOOD, 'pattern', ['barilla spaghetti', 'barilla pasta'], 0.28, 'Known grocery product pattern matched.'), ]; } private function rule(string $domain, string $type, array $values, float $weight, string $reason): array { return compact('domain', 'type', 'values', 'weight', 'reason'); } }