-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
36 lines (29 loc) · 943 Bytes
/
index.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
<?php
/**
* @file
* Demonstration file of using TagConverter library.
*/
require 'vendor/autoload.php';
use writecrow\Tokenizer\Tokenizer;
$file = file_get_contents('demo_text.txt', FILE_USE_INCLUDE_PATH);
if (isset($_POST['text'])) {
$file = $_POST['text'];
}
include 'head.html';
echo '
<form action="//' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '" method="POST">
<label for="text"><strong>Text to be tokenized</strong></label><br />
<em>(Paste your text below)</em><br />
<textarea class="u-full-width textbox" placeholder="Place your text here..." name="text">' . $file . '</textarea><br />
<input class="btn" type="submit" value="Tokenize (& count words)" />';
if (isset($_POST['text'])) {
$tokens = Tokenizer::tokenize($_POST['text']);
echo '<h3>Word count: ' . count($tokens) . '</h3>';
echo '<div><pre><code>';
print_r($tokens);
echo '</code></pre></div>';
}
echo '
</form>
</body>
</html>';