dennis-de-swart / php-stanford-nlp-datastore
存储来自Stanford CoreNLP服务器的NLP数据。
2.2.0
2017-02-08 21:56 UTC
Requires
- php: >=5.3
- dennis-de-swart/php-stanford-corenlp-adapter: *
- doctrine/dbal: *
This package is auto-updated.
Last update: 2024-08-29 04:25:28 UTC
README
存储来自Stanford CoreNLP服务器的NLP数据。
它做什么?
它使用Stanford CoreNLP服务器分析文本,然后存储结果。
哪些数据会被存储?
- OpenIE:这些是“主题-关系-对象”三元组。这个概念类似于“主题-谓语-对象”三元组。
http://stanfordnlp.github.io/CoreNLP/openie.html
- 命名实体:如果一个词是“命名实体”,比如地点、名称或时间,它将存储这些数据
http://stanfordnlp.github.io/CoreNLP/ner.html
- 共指:如果有一个句子中对某个词的引用。
http://stanfordnlp.github.io/CoreNLP/coref.html
它是如何工作的?
- 您提交一个文本。
- 文本由Stanford CoreNLP服务器进行分析
- 结果存储在一个基于SQLite文件的数据库中。数据库文件名为"datastore.db"
https://sqlite.ac.cn/
https://github.com/sqlitebrowser
- 结果将在屏幕上显示
- 还有一个搜索表单来查找数据
此包依赖于Stanford CoreNLP服务器
http://stanfordnlp.github.io/CoreNLP/index.html#download
此包还依赖于PHP-Stanford-CoreNLP-Adapter
https://github.com/DennisDeSwart/php-stanford-corenlp-adapter
注意:由于此包包含完整的CoreNLP Adapter版本,您可以使用此包的所有功能。
安装
此包依赖于以下包
http://stanfordnlp.github.io/CoreNLP/index.html#download
https://github.com/DennisDeSwart/php-stanford-corenlp-adapter
https://github.com/doctrine/dbal
https://github.com/guzzle/guzzle
使用ZIP文件安装的安装过程
- 安装Stanford CoreNLP服务器。检查"php-stanford-corenlp-adapter"包以获取安装教程
- 下载并解压此包中的文件。
- 将文件复制到您的web服务器目录中。通常是"htdocs"或"var/www"。
- 运行Composer更新以安装依赖项
作为其他项目的一部分安装
- 安装Stanford CoreNLP服务器。检查"php-stanford-corenlp-adapter"包以获取安装教程
- 将以下行添加到主项目的"composer.json"的require部分
{
"require": {
"dennis-de-swart/php-stanford-nlp-datastore": "*"
}
}
- 运行Composer更新以安装依赖项
Copy these files from "/vendor/dennis-de-swart/php-stanford-nlp-datastore" to your webserver directory. Usually "htdocs" or "var/www".
- datastore.db
- bootstrap.php
- 主项目的示例代码
// instantiate constants and the database
require_once __DIR__.'/bootstrap.php';
// startup Corenlp Adapter
$coreNLP = new CorenlpAdapter();
$coreNLP->getOutput($yourText);
print_r($coreNLP->serverMemory); // result from CoreNLP Adapter
// Save result to database
$datastore = new Datastore($db->conn);
$datastore->storeNLP($coreNLP);
要求
- PHP 5.6或更高版本:它也适用于PHP 7
- Java SE运行环境,版本1.8
- Stanford CoreNLP服务器3.7.0
- Windows或Linux/Unix 64位操作系统,建议至少8GB内存。
- PHP的Composer
https://getcomposer.org.cn/
SQLite浏览器
如果您需要SQLite浏览器,请在此处检查
http://sqlitebrowser.org/
重要提示
- 首次启动CoreNLP服务器需要一些时间,因为它将加载大量数据。
- 首次启动后,服务器将快得多。
- 根据我的经验,Stanford CoreNLP服务器在8GB或更多内存的情况下运行最佳。用"-mx8g"而不是"-mx4g"启动服务器。
- 还要使用服务器的3.7.0版本,这将给您提供最佳和最快的性能。
示例输出
查看
- "datastore_result_a.PNG"
- "datastore_result_b.PNG"
- "datastore_result_search.PNG"
和"example.db",这是一个已填充数据库的外观
有任何问题吗?
请告诉我。您可以在GitHub上创建一个问题。任何错误都将立即修复。