-
Notifications
You must be signed in to change notification settings - Fork 4
/
train.php
26 lines (22 loc) · 866 Bytes
/
train.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
<?php
// error outputting for debugging
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$directory = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$library = $directory . 'lib' . DIRECTORY_SEPARATOR;
$data = $directory . 'trainingdata' . DIRECTORY_SEPARATOR;
require $library . 'GibberishDetector.php';
$dictionary = file( $data . 'dictionary.txt' );
$good = file( $data . 'good.txt' );
$bad = file( $data . 'bad.txt' );
$gibber = new GibberishDetector();
$gibber->train( $dictionary, $good, $bad );
$serialized_cache = $gibber->export_model();
$raw_cache = $gibber->export_model( false );
?>
<h1>Training Results</h1>
<h3>Serialized Model</h3>
<pre><?php echo $serialized_cache; ?></pre>
<h3>PHP Model</h3>
<pre><?php echo var_export( $raw_cache ); ?></pre>