Download the PHP package hocvt/rake-php-plus without Composer
On this page you can find all versions of the php package hocvt/rake-php-plus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hocvt/rake-php-plus
More information about hocvt/rake-php-plus
Files in hocvt/rake-php-plus
Package rake-php-plus
Short Description Yet another PHP implementation of the Rapid Automatic Keyword Extraction algorithm (RAKE).
License MIT
Homepage https://github.com/Donatello-za/rake-php-plus
Informations about the package rake-php-plus
rake-php-plus
A keyword and phrase extraction library based on the Rapid Automatic Keyword Extraction algorithm (RAKE).
This repo for custom usage only
Introduction
Keywords describe the main topics expressed in a document/text. Keyword extraction in turn allows for the extraction of important words and phrases from text.
Extracted keywords can be used for things like:
- Building a list of useful tags out of a larger text
- Building search indexes and search engines
- Grouping similar content by its topic.
Extracted phrases can be used for things like:
- Highlighting important areas of a larger text
- Language or documentation analysis
- Building intelligent searches based on contextual terms
This library provides an easy method for PHP developers to get a list of keywords and phrases from a string of text and is based on another smaller and unmaintained project called RAKE-PHP by Richard Filipčík, which is a translation from a Python implementation simply called RAKE.
As described in: Rose, S., Engel, D., Cramer, N., & Cowley, W. (2010). Automatic Keyword Extraction from Individual Documents. In M. W. Berry & J. Kogan (Eds.), Text Mining: Theory and Applications: John Wiley & Sons.
This particular package intends to include the following benefits over the original RAKE-PHP package:
- PSR-2 coding standards.
- PSR-4 to be Composer installable.
- Additional functionality such as method chaining.
- Multiple ways to provide source stopwords.
- Full unit test coverage.
- Performance improvements.
- Improved documentation.
- Easy language integration and multibyte string support.
Currently Supported Languages
- Afrikaans (af_ZA)
- Arabic (United Arab Emirates)/لإمارات العربية المتحدة (ar_AE)
- Brazilian Portuguese/português do Brasil (pt_BR)
- English US (en_US)
- European Portuguese/português europeu (pt_PT)
- French/le français (fr_FR)
- German (Germany)/Deutsch (Deutschland) (de_DE)
- Italian/italiano (it_IT)
- Polish/język polski (pl_PL)
- Russian/русский язык (ru_RU)
- Sorani Kurdish/سۆرانی (ckb_IQ)
- Spanish/español (es_AR)
- Tamil/தமிழ் (ta_TA)
- Turkish/Türkçe (tr_TR)
- Persian/Farsi/فارسی (fa_IR)
- Dutch/Nederlands (nl_NL)
- Swedish/svenska (sv_SE)
If your language is not listed here it can be added, please see the section called How to add additional languages at the bottom of the page.
Version
v1.0.19
Special Thanks
- Jarosław Wasilewski: Polish language and improving multi-byte support.
- Lev Morozov: French and Russian languages.
- Igor Carvalho: Brazilian Portuguese language.
- Khoshbin Ali Ahmed: Sorani Kurdish and Arabic languages.
- RhaPT: European Portuguese language.
- Peter Thaleikis: German language.
- Yusuf Usta: Turkish language.
- orthosie: Tamil language.
- ScIEnzY: Italian language.
- Reza Rabbani: Persian language.
- Anne van der Aar: Dutch language.
Installation
With Composer
Without Composer
Example 1
Creates a new instance of RakePlus, extract the phrases and return the results. Assumes that the specified text is English (US).
Example 2
Creates a new instance of RakePlus, extract the phrases in different orders and also shows how to get the phrase scores.
Example 3
Creates a new instance of RakePlus and extract the unique keywords from the phrases.
Example 4
Creates a new instance of RakePlus without using the static RakePlus::create method.
Example 5
You can provide custom stopwords in four different ways:
Example 6
You can specify the minimum number of characters that a phrase\keyword must be and if less than the minimum it will be filtered out. The default is 0 (no minimum).
Example 7
You can specify whether phrases\keywords that consists of a numeric number only should be filtered out or not. The default is to filter out numerics.
How to add additional languages
The library requires a list of "stopwords" for each language. Stopwords are common words used in a language such as "and", "are", "or", etc.
There are stopwords for 50 languages (including the ones already supported) available in JSON format. If you are lucky enough to have your language listed then you can easily import it into the library. To do so, read the section below:
Using the stopwords extractor tool
Note: These instructions assumes you are using Linux
We will be using the Greek language as an example:
- Check to see if your operating have the Greek localisation files, the Greek locale
code you have to look for is:
el_GR
. So run the command$ locale -a
to see if it is listed. -
If it is not listed, you'll need to create it, so run:
- Go the list of stopword files and
find the Greek language, the file will be called
el.json
and it will contain 75 stopwords. - Download the
el.json
file and store it somewhere on your system. - In you terminal, go to the directory of the
rake-php-plus
library, it will be undervendor/donatello-za/rake-php-plus
if you used Composer to install it.
We now need to use the JSON file to create two new files, one will be a .php
file
that contains the stopwords as a PHP array and one fill be a .pattern
file which
is a text file containing the stopwords as a regular expression:
-
Extract and convert the .json file to a PHP file by running:
- Extract and convert the .json file to a .pattern file by running:
That is it! You can now use the new stopwords by specifying it when creating an instance of the RakePlus class, for example:
or
Contribute by Adding a Language
If you want your language to be officially support, you can fork this library,
generate the .pattern
and .php
stopword files as described above, place it
in the ./rake-php-plus/lang/
directory and submit it as a pull request.
Once your language is officially supported, you'll be able to specify the language without having to specify the file to use, for example:
RakePHP will always look for a .pattern
file first and if not found it will
look for a .php
file in the ./lang/
directory.
I don't have a stopwords file for my language, what now?
If your language is not covered in the list of 50 languages here you may have to try and find it elsewhere, try searching for "yourlanguage stopwords". If you find a list or decide to create your own list, you can also just place it in a standard text file instead of a .json file and extract the stopwords using the extractor tool, for example:
Remember to replace LOCAL_CODE
for the correct local you wish to use.
Here is an example text file containing stopwords that was copied and pasted from a site: stopwords_en_US
To run tests
Unit testing is performed using PHPUnit v11.2 running on PHP v8.3.0+.
./vendor/bin/phpunit tests
License
Released under MIT license (read LICENSE).
All versions of rake-php-plus with dependencies
ext-json Version *
ext-mbstring Version *