-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdemo_blob_builder.php
More file actions
49 lines (36 loc) · 1.39 KB
/
demo_blob_builder.php
File metadata and controls
49 lines (36 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* @copyright 2025 Nito T.M.
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache-2.0
* @author Nito T.M. (https://github.com/nitotm)
* @package nitotm/efficient-language-detector
*/
require_once __DIR__ . '/manual_loader.php';
// require __DIR__ . '/vendor/autoload.php';
use Nitotm\Eld\BlobDataBuilder;
use Nitotm\Eld\EldDataFile;
$cliHelp = <<<TXT
Options:
-d for database: small, medium, large, extralarge (& subsets)
-l for languages: Optional, creates subset, comma-separated language codes
CLI example:
php demo_blob_builder.php -d small -l en,es,de,it
TXT;
$database = EldDataFile::SMALL;
$languages = null;
if (PHP_SAPI === 'cli') {
echo $cliHelp . PHP_EOL;
$arguments = getopt("d:l:") ?: [];
$database = $arguments['d'] ?? $database;
$languageString = $arguments['l'] ?? null;
if ($languageString) {
$languages = explode(',', $languageString);
}
}
// Builds a low memory database for EDL modes 'string', 'bytes' & 'disk', from any 'array' database
// It will load an 'array' database, memory requirements for 'array' input database apply
$eldBuilder = new BlobDataBuilder($database, $languages);
// Database files: 'small', 'medium', 'large', 'extralarge' & subsets. Check memory requirements at README
// Language subset
// $eldBuilder = new BlobDataBuilder(EldDataFile::SMALL, ['en', 'es', 'de', 'it']);
$eldBuilder->buildDatabase();