From a25508089eb4ead895006d10168007993b8f416f Mon Sep 17 00:00:00 2001 From: Rastislav Chynoransky Date: Fri, 13 Dec 2024 16:15:39 +0700 Subject: [PATCH] [import] Match author role separated by dash --- app/Matchers/AuthorityMatcher.php | 4 ++-- tests/Matchers/AuthorityMatcherTest.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Matchers/AuthorityMatcher.php b/app/Matchers/AuthorityMatcher.php index 58e5e5b68..10b0215b1 100644 --- a/app/Matchers/AuthorityMatcher.php +++ b/app/Matchers/AuthorityMatcher.php @@ -97,14 +97,14 @@ protected function findByFullname($fullname) public static function parse($author) { - if (!preg_match('/^((?.*?)\s*(?\(.*\))?(?\s+-\s+.*)?,\s+)?(?.*?)\s*(?\(.*\)|\/.*)?$/', $author, $matches)) { + if (!preg_match('/^((?.*?)\s*(?\(.*\))?(?\s+[-–]\s+.*)?,\s+)?(?.*?)\s*(?\(.*\)|\/.*)?$/', $author, $matches)) { return null; } return [ 'surname' => $matches['surname'] ?: null, 'alt_surname' => trim($matches['alt_surname'], '()') ?: null, - 'role' => ltrim($matches['role'], ' -') ?: null, + 'role' => ltrim($matches['role'], ' -–') ?: null, 'name' => $matches['name'] ?: null, 'alt_name' => trim($matches['alt_name'] ?? '', '()/') ?: null, ]; diff --git a/tests/Matchers/AuthorityMatcherTest.php b/tests/Matchers/AuthorityMatcherTest.php index 3af7844f1..1490a9db6 100644 --- a/tests/Matchers/AuthorityMatcherTest.php +++ b/tests/Matchers/AuthorityMatcherTest.php @@ -7,10 +7,11 @@ use App\Matchers\AuthorityMatcher; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; +use Tests\WithoutSearchIndexing; class AuthorityMatcherTest extends TestCase { - use RefreshDatabase; + use RefreshDatabase, WithoutSearchIndexing; public function testMatchAll() {