PHP Science TextRank
Arabic & Turkish languages support
该源代码是 TextRank 算法在 PHP 编程语言中的实现,获得 MIT 许可。
ChatGPT 等 GPT 是受监督的语言模型,可以理解上下文并使用大量资源从给定输入生成新内容,而 TextRank 是一种经济高效/低成本的文本提取算法。 TextRank 算法还可以用作 GPT 模型的预处理器,以减小文本大小以节省资源消耗。
自动摘要是使用计算机程序缩减文本文档以创建保留原始文档最重要要点的摘要的过程。能够做出连贯摘要的技术会考虑长度、写作风格和语法等变量。自动数据摘要是机器学习和数据挖掘的一部分。概括的主要思想是找到数据的一个有代表性的子集,它包含了整个集合的信息。当今工业的许多部门都使用摘要技术。 - 维基百科
本次实现的算法为:
cd your-project-folder
composer require php-science/textrank
cd git-project-folder
docker-compose build
docker-compose up -d
composer install
composer test
use PhpScience TextRank Tool StopWords English ;
// String contains a long text, see the /res/sample1.txt file.
$ text = " Lorem ipsum... " ;
$ api = new TextRankFacade ();
// English implementation for stopwords/junk words:
$ stopWords = new English ();
$ api -> setStopWords ( $ stopWords );
// Array of the most important keywords:
$ result = $ api -> getOnlyKeyWords ( $ text );
// Array of the sentences from the most important part of the text:
$ result = $ api -> getHighlights ( $ text );
// Array of the most important sentences from the text:
$ result = $ api -> summarizeTextBasic ( $ text );
更多示例:
姓名 | GitHub 用户 |
---|---|
大卫·贝利查 | @大卫贝利扎 |
里卡多·马顿 | @riccardomarton |
辛德西 | @辛德西 |
文森奇 | @vincentsch |
安德鲁韦尔奇 | @khalwat |
安德烈·阿斯塔索夫 | @mvcaaa |
利奥·托内夫 | @布拉格 |
威利·阿里斯基 | @willyarisky |
罗伯特·扬·凯泽 | @KeizerDev |
莫蒂 | @邪恶1莫蒂 |
塞泽尔·菲丹西 | @SezerFidanci |