-
Notifications
You must be signed in to change notification settings - Fork 0
/
standard.php
53 lines (40 loc) · 1.19 KB
/
standard.php
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
50
51
52
53
<?php
/*
* This file is part of Pucene.
*
* (c) asapo.at
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
require dirname(__DIR__) . '/vendor/autoload.php';
use Pucene\Analysis\StandardAnalyzer;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Style\SymfonyStyle;
$style = new SymfonyStyle(new ArgvInput(), new ConsoleOutput());
$table = $style->createTable();
$style->writeln((string) file_get_contents(__DIR__ . '/logo.txt'));
$style->title('Standard Analyzer');
$style->text(<<<EOF
This example analyses a text with the standard analyzer:
EOF);
$style->note('Analysing: "The 2 QUICK Brown-Foxes jumped over the lazy dog\'s bone."');
$analyzer = new StandardAnalyzer();
$tokens = $analyzer->analyze('The 2 QUICK Brown-Foxes jumped over the lazy dog\'s bone.');
$table->setHeaders([
'Term',
'Start Offset',
'End Offset',
'Position',
]);
foreach ($tokens as $token) {
$table->addRow([
$token->term,
$token->startOffset,
$token->endOffset,
$token->position,
]);
}
$table->render();
$style->newLine();