php - php中的word2vec
问题描述
我对 ML 相当陌生,不知道事情是如何工作的,我有一个带搜索栏的网页。我需要使用 word2vec 在搜索栏中完成用户输入。
我正在使用来自https://github.com/donlinglok/C-word2vec-php的代码
<?php
$txtfilepath = fopen("options.txt", "r") or die("Unable to open file!");
echo fread($txtfilepath, filesize("options.txt"));
//fclose($txtfilepath);
function train($txtfilepath) {
$cbow = 1;
$size = 500;
$window = 10;
$negative = 10;
$hs = 0;
$sample = "1e-5";
$threads = 40;
$binary = 1;
$iter = 3;
$min_count = 10;
exec ( "cd " . dirname ( __FILE__ ) . "/google-word2vec-trunk && ./word2vec " . " -train " . $txtfilepath . " -output " . dirname ( __FILE__ ) . "/vectors.bin " . " -cbow " . $cbow . " -size " . $size . " -window " . $window . " -negative " . $negative . " -hs " . $hs . " -sample " . $sample . " -threads " . $threads . " -binary " . $binary . " -iter " . $iter . " -min-count " . $min_count, $outputArray );
}
function distance($keyword) {
exec ( "cd " . dirname ( __FILE__ ) . " && ./distancecli " . dirname ( __FILE__ ) . "/vectors.bin " . $keyword, $outputArray );
if (isset ( $outputArray[0] )) {
return $outputArray;
} else {
return distance ( $keyword );
}
}
//train ( dirname ( __FILE__ ) . "/google-word2vec-trunk/questions-words.txt" );
echo json_encode ( distance ( "facebook" ), true );
?>
我下一步该怎么做?如何运行此代码并在搜索栏中获取结果?我从网络文件夹 http://localhost/trainmodel/word2vec.php 运行它并收到此错误致命错误:
第 23 行的 C:\xampp\htdocs\trainmodel\word2vec.php 中超过了 30 秒的最大执行时间
解决方案
推荐阅读
- java - 如何让 ImageIcon 在所有平台上工作
- mysql - XAMPP 无法开始运行 MySQL
- c - Volatile int vs int 变量效应
- http - 我想在 Elm 中初始化函数
- flutter - 什么主题元素控制 TextField 小部件的焦点颜色
- angular - Angular 8 - 如何拦截来自(rxjs)的http错误?
- ios - 如何从 AppDelegate 显示 iOS 13 SwiftUI 视图?
- laravel - Laravel:如何检查数组是否为空?
- python - 如何修复 for 循环中的“KeyError:2”?
- sql - 获取员工最近的薪水