Commit ee238f5f authored by asajedi's avatar asajedi
Browse files

Merge branch 'adaptEntityName' into 'master'

Adapt entity name

See merge request !10
parents 466663e4 76623879
Pipeline #231221 passed with stages
in 6 minutes and 34 seconds
......@@ -27,3 +27,5 @@ yarn-error.log
###> symfony/web-server-bundle ###
/.web-server-pid
###< symfony/web-server-bundle ###
/teis
\ No newline at end of file
......@@ -87,7 +87,7 @@ services:
App\Service\FileService:
arguments: ["@cache_filesystem", "@source_filesystem", "@pdf_filesystem", "@image_filesystem", "@tei_filesystem"]
App\Controller\SimplexmlController:
App\Controller\Tei2SolrController:
calls:
- method: 'setConfigs'
arguments:
......
......@@ -4,23 +4,21 @@ declare(strict_types=1);
namespace App\Command;
use App\Controller\SimplexmlController;
use App\Controller\Tei2SolrController;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
//use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\KernelInterface;
class SolrIndexing extends Command
{
private SimplexmlController $simplexmlController;
private Tei2SolrController $tei2SolrController;
protected $projectDir;
public function __construct(SimplexmlController $simplexmlController, KernelInterface $kernel)
public function __construct(Tei2SolrController $tei2SolrController, KernelInterface $kernel)
{
parent::__construct();
$this->simplexmlController = $simplexmlController;
$this->tei2SolrController = $tei2SolrController;
$this->projectDir = $kernel->getProjectDir();
}
......@@ -41,9 +39,9 @@ class SolrIndexing extends Command
{
$output->writeln('Start solr indexing.');
$this->simplexmlController->fetchTeis();
$this->simplexmlController->deleteSolrIndex();
$this->simplexmlController->tei2solr();
$this->tei2SolrController->fetchTeis();
$this->tei2SolrController->deleteSolrIndex();
$this->tei2SolrController->tei2solr();
$time = microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'];
$time = $time/60;
......
......@@ -2,7 +2,6 @@
namespace App\Controller;
use App\Model\SolrDocument;
use DOMDocument;
use DOMXPath;
......@@ -14,7 +13,7 @@ use Symfony\Component\Routing\Annotation\Route;
use Solarium\Client;
use Symfony\Component\Finder\Finder;
class SimplexmlController extends AbstractController
class Tei2SolrController extends AbstractController
{
private Client $client;
......@@ -457,6 +456,17 @@ class SimplexmlController extends AbstractController
$documentGndsNodes = $xpath->query('//tei:text[@xml:lang="ger"]//tei:name');
$documentEntities = [];
foreach ($documentGndsNodes as $documentGndsNode) {
if (is_iterable($documentGndsNode->childNodes)) {
$entityName = '';
foreach ($documentGndsNode->childNodes as $childNode) {
if (!empty($childNode->data)) {
$entityName .= ' ' . trim(preg_replace('/\s+/', ' ', $childNode->data));
}
}
$entityName = str_replace('- ', '', $entityName);
}
foreach ($documentGndsNode->attributes as $attribute) {
if (strstr($attribute->nodeValue, 'gnd')) {
$gnd = str_replace('gnd:', '', $attribute->nodeValue);
......@@ -466,10 +476,6 @@ class SimplexmlController extends AbstractController
}
}
if (!empty($documentGndsNode->nodeValue)) {
$entityName = trim(preg_replace('/\s+/', ' ', $documentGndsNode->nodeValue));
}
if (isset($entityName) && isset($type) && isset($gnd)) {
$entities[] = ['doctype' => 'entity', 'name' => $entityName, 'entity_type' => $type, 'gnd' => $gnd];
}
......@@ -907,7 +913,6 @@ class SimplexmlController extends AbstractController
&& $e->parentNode->nodeName !== 'note'
) {
if (isset($add) && !empty($add)) {
$tText .= ' &lang;' . $e->data . ' ' . $add;
......@@ -943,7 +948,7 @@ class SimplexmlController extends AbstractController
$italic = true;
}
} elseif (isset($gnd) && true === $gnd) {
$eText .= $e->data . '</span>';
$eText .= '</span>';
$tText .= $e->data;
$gnd = false;
} else {
......@@ -1068,10 +1073,27 @@ class SimplexmlController extends AbstractController
}
}
} elseif ('name' === $e->nodeName && (isset($e->attributes[1]->value) && !empty($e->attributes[1]->value)) && (isset($e->attributes[0]->value) && !empty($e->attributes[0]->value))) {
$entityName = '';
foreach ($e->childNodes as $childNode) {
if (!empty($childNode->data)) {
$entityName .= ' '.trim(preg_replace('/\s+/', ' ', $childNode->data));
}
}
$entityName = str_replace('- ', '', $entityName);
$uuid = $this->getUuid();
$gndsUuids[$uuid] = str_replace('gnd:', '', $e->attributes[1]->value);
$pagesGndsUuids[$k][$uuid] = str_replace('gnd:', '', $e->attributes[1]->value);
$eText .= '<span class="' . $e->attributes[0]->value . '" id="' . $uuid . '">';
if (str_contains($e->attributes[1]->value, 'gnd.')) {
$gndsUuids[$uuid] = str_replace('gnd.', '', $e->attributes[1]->value);
$pagesGndsUuids[$k][$uuid] = str_replace('gnd.', '', $e->attributes[1]->value);
} elseif (str_contains($e->attributes[1]->value, 'gnd:')) {
$gndsUuids[$uuid] = str_replace('gnd:', '', $e->attributes[1]->value);
$pagesGndsUuids[$k][$uuid] = str_replace('gnd:', '', $e->attributes[1]->value);
}
$eText .= '<span class="' . $e->attributes[0]->value . '" id="' . $uuid . '">'.$entityName;
$gnd = true;
}
}
......
......@@ -280,7 +280,6 @@
<addrLine rendition="simple:right">Hier.</addrLine>
</address>
</opener>
</div>
<div>
<cb rendition="simple:column-right"/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment