keevitaja/language-detector-socket
最新稳定版本:v0.0.5
Composer 安装命令:
composer require keevitaja/language-detector-socket
包简介
A high-performance PHP language detection service using Unix sockets and Efficient Language Detector.
关键字:
README 文档
README
A high-performance language detection service written in PHP using Unix sockets and Efficient Language Detector.
Installation
composer require keevitaja/language-detector-socket
Important
Enable OPcache for CLI to avoid excessive CPU usage. The LanguageDetector library loads and compiles large language model data files on every request. Without OPcache, PHP will recompile these files repeatedly, causing significant CPU overhead.
opcache.enable_cli=1
Usage
Start the Server
use Keevitaja\LanguageDetectorSocket\Server; $server = new Server([ 'socket' => '/tmp/language-detector.sock', ]); $server->run();
Use the Client
use Keevitaja\LanguageDetectorSocket\Client; $client = new Client([ 'socket' => '/tmp/language-detector.sock', ])->make(); $scores = $client->detect('Hello world'); // ['en' => 0.95, 'nl' => 0.03, ...] $client->close();
Configuration defaults
[
// Unix socket path
'socket' => '/tmp/language.detector.sock',
// Number of worker processes
'processes' => 1,
// Connection timeout in seconds
'timeout' => 10,
// Limit detection to specific languages (null = all or ['en', 'nl'])
'locales' => null,
// Language model size (SMALL, MEDIUM, LARGE)
'eldDataFile' => EldDataFile::SMALL,
// Language code format (ISO639_1, ISO639_3)
'eldFormat' => EldFormat::ISO639_1,
// Path to store the worker process ID file
'workerPidFile' => '/tmp/language.detector.worker.pid',
// Path to store the worker log file
'workerLogFile' => '/tmp/language.detector.worker.log',
// Path to store the worker an stdout log file
'workerStdoutFile' => '/tmp/language.detector.worker.stdout.log',
// Whether to run the worker as a daemon process
'workerDemonize' => false,
]
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-18