-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathword2vec.php
executable file
·56 lines (41 loc) · 1.05 KB
/
word2vec.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
54
55
56
<?php
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
/**
* Word2Vec
*
* @package Word2Vec GUI
*/
// Configure server
set_time_limit (0);
ini_set ('memory_limit', '-1');
// Require autload
require ('vendor/autoload.php');
/** @var train_file String */
$train_file = './tmp/quijote.txt';
/** @var output_file String */
$output_file = './tmp/vectors.bin';
/** @var command String */
$command =
'./vendor/google-word2vec-trunk/word2vec '
. ' -train ' . $train_file
. ' -output ' . $output_file
. ' -cbow 1'
. ' -size 200'
. ' -window 8 '
. ' -negative 25'
. ' -hs 0'
. ' -sample 1e-4'
. ' -threads 20'
. ' -binary 1'
. ' -iter 15'
;
$process = new Process ($command);
$process->start();
foreach ($process as $type => $data) {
if ($process::OUT === $type) {
echo "\nRead from stdout: ".$data;
} else { // $process::ERR === $type
echo "\nRead from stderr: ".$data;
}
}