From f1309a1be3824fd12a528e4aed4de12a17ca49b3 Mon Sep 17 00:00:00 2001
From: David Belicza <87.bdavid@gmail.com>
Date: Sun, 20 Sep 2020 16:55:12 +0200
Subject: [PATCH 1/5] Prepare the package for refactoring
---
.github/workflows/tests.yml | 39 +
.gitignore | 4 +-
.travis.yml | 11 -
LICENSE | 21 +
composer.json | 15 +-
composer.lock | 1409 -----------------
phpunit.xml | 27 -
readme.md | 105 +-
src/TextRankFacade.php | 7 -
src/Tool/Graph.php | 15 -
src/Tool/Parser.php | 14 -
src/Tool/Score.php | 14 -
src/Tool/StopWords/English.php | 12 -
src/Tool/StopWords/French.php | 12 -
src/Tool/StopWords/German.php | 15 +-
src/Tool/StopWords/Italian.php | 5 -
src/Tool/StopWords/Norwegian.php | 12 -
src/Tool/StopWords/Russian.php | 13 -
src/Tool/StopWords/Spanish.php | 12 -
src/Tool/StopWords/StopWordsAbstract.php | 12 -
src/Tool/Summarize.php | 14 -
src/Tool/Text.php | 14 -
tests/{ => functional}/TextRankFacadeTest.php | 11 +-
tests/phpunit.xml | 34 +
{res => tests/resource}/sample1.txt | 0
25 files changed, 144 insertions(+), 1703 deletions(-)
create mode 100644 .github/workflows/tests.yml
delete mode 100644 .travis.yml
create mode 100644 LICENSE
delete mode 100644 composer.lock
delete mode 100644 phpunit.xml
rename tests/{ => functional}/TextRankFacadeTest.php (93%)
create mode 100644 tests/phpunit.xml
rename {res => tests/resource}/sample1.txt (100%)
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
new file mode 100644
index 0000000..f3f4b41
--- /dev/null
+++ b/.github/workflows/tests.yml
@@ -0,0 +1,39 @@
+name: tests
+
+on:
+ push:
+ pull_request:
+
+jobs:
+ run:
+ runs-on: ${{ matrix.operating-system }}
+ strategy:
+ matrix:
+ operating-system: [ubuntu-latest]
+ php-versions: ['7.4']
+ name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php-versions }}
+ coverage: xdebug
+
+ - name: Validate composer files
+ run: composer validate
+
+ - name: Install dependencies
+ if: steps.composer-cache.outputs.cache-hit != 'true'
+ run: composer install --prefer-dist --no-progress --no-suggest
+
+ - name: Run test suite
+ run: composer test
+
+ - name: Publish Analysis
+ uses: codecov/codecov-action@v1.0.13
+ with:
+ name: Code Analysis
+ directory: ./var/code-coverage/clover/coverage.xml
diff --git a/.gitignore b/.gitignore
index ab27d1e..fa374aa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
/.idea
-/vendor
\ No newline at end of file
+/composer.lock
+/vendor
+/var
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 0895ccb..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-language: php
-php:
- - '7.1'
- - '7.2'
-
-dist: trusty
-sudo: required
-group: edge
-
-before_script:
- - composer install
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..29afed1
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2020 PHP-Science
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/composer.json b/composer.json
index 4d07d2e..3dc3015 100644
--- a/composer.json
+++ b/composer.json
@@ -10,19 +10,24 @@
}
],
"require": {
- "php": "7.*",
+ "php": "7.4.*",
"ext-ctype": "*",
- "ext-mbstring": "*"
+ "ext-mbstring": "*",
+ "php-science/pagerank": "1.*"
},
"require-dev": {
- "phpunit/phpunit": "^5.4"
+ "phpunit/phpunit": "^9"
},
"autoload": {
"psr-4": {
- "PhpScience\\TextRank\\": ["src/", "tests/"]
+ "PhpScience\\TextRank\\": [
+ "src/",
+ "tests/unit/",
+ "tests/functional/"
+ ]
}
},
"scripts": {
- "test": "phpunit --colors='always' $(pwd)/tests"
+ "test": "vendor/bin/phpunit -c $(pwd)/tests/phpunit.xml --colors='always' --do-not-cache-result"
}
}
diff --git a/composer.lock b/composer.lock
deleted file mode 100644
index 65ae386..0000000
--- a/composer.lock
+++ /dev/null
@@ -1,1409 +0,0 @@
-{
- "_readme": [
- "This file locks the dependencies of your project to a known state",
- "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
- "This file is @generated automatically"
- ],
- "content-hash": "97ff0c108502ab602ba79bf3a251e208",
- "packages": [],
- "packages-dev": [
- {
- "name": "doctrine/instantiator",
- "version": "1.1.0",
- "source": {
- "type": "git",
- "url": "https://github.com/doctrine/instantiator.git",
- "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda",
- "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda",
- "shasum": ""
- },
- "require": {
- "php": "^7.1"
- },
- "require-dev": {
- "athletic/athletic": "~0.1.8",
- "ext-pdo": "*",
- "ext-phar": "*",
- "phpunit/phpunit": "^6.2.3",
- "squizlabs/php_codesniffer": "^3.0.2"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.2.x-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Marco Pivetta",
- "email": "ocramius@gmail.com",
- "homepage": "http://ocramius.github.com/"
- }
- ],
- "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
- "homepage": "https://github.com/doctrine/instantiator",
- "keywords": [
- "constructor",
- "instantiate"
- ],
- "time": "2017-07-22T11:58:36+00:00"
- },
- {
- "name": "myclabs/deep-copy",
- "version": "1.8.1",
- "source": {
- "type": "git",
- "url": "https://github.com/myclabs/DeepCopy.git",
- "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8",
- "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8",
- "shasum": ""
- },
- "require": {
- "php": "^7.1"
- },
- "replace": {
- "myclabs/deep-copy": "self.version"
- },
- "require-dev": {
- "doctrine/collections": "^1.0",
- "doctrine/common": "^2.6",
- "phpunit/phpunit": "^7.1"
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "DeepCopy\\": "src/DeepCopy/"
- },
- "files": [
- "src/DeepCopy/deep_copy.php"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "description": "Create deep copies (clones) of your objects",
- "keywords": [
- "clone",
- "copy",
- "duplicate",
- "object",
- "object graph"
- ],
- "time": "2018-06-11T23:09:50+00:00"
- },
- {
- "name": "phpdocumentor/reflection-common",
- "version": "1.0.1",
- "source": {
- "type": "git",
- "url": "https://github.com/phpDocumentor/ReflectionCommon.git",
- "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6",
- "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6",
- "shasum": ""
- },
- "require": {
- "php": ">=5.5"
- },
- "require-dev": {
- "phpunit/phpunit": "^4.6"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0.x-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "phpDocumentor\\Reflection\\": [
- "src"
- ]
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Jaap van Otterdijk",
- "email": "opensource@ijaap.nl"
- }
- ],
- "description": "Common reflection classes used by phpdocumentor to reflect the code structure",
- "homepage": "http://www.phpdoc.org",
- "keywords": [
- "FQSEN",
- "phpDocumentor",
- "phpdoc",
- "reflection",
- "static analysis"
- ],
- "time": "2017-09-11T18:02:19+00:00"
- },
- {
- "name": "phpdocumentor/reflection-docblock",
- "version": "4.3.0",
- "source": {
- "type": "git",
- "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
- "reference": "94fd0001232e47129dd3504189fa1c7225010d08"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08",
- "reference": "94fd0001232e47129dd3504189fa1c7225010d08",
- "shasum": ""
- },
- "require": {
- "php": "^7.0",
- "phpdocumentor/reflection-common": "^1.0.0",
- "phpdocumentor/type-resolver": "^0.4.0",
- "webmozart/assert": "^1.0"
- },
- "require-dev": {
- "doctrine/instantiator": "~1.0.5",
- "mockery/mockery": "^1.0",
- "phpunit/phpunit": "^6.4"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "4.x-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "phpDocumentor\\Reflection\\": [
- "src/"
- ]
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Mike van Riel",
- "email": "me@mikevanriel.com"
- }
- ],
- "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
- "time": "2017-11-30T07:14:17+00:00"
- },
- {
- "name": "phpdocumentor/type-resolver",
- "version": "0.4.0",
- "source": {
- "type": "git",
- "url": "https://github.com/phpDocumentor/TypeResolver.git",
- "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7",
- "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7",
- "shasum": ""
- },
- "require": {
- "php": "^5.5 || ^7.0",
- "phpdocumentor/reflection-common": "^1.0"
- },
- "require-dev": {
- "mockery/mockery": "^0.9.4",
- "phpunit/phpunit": "^5.2||^4.8.24"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0.x-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "phpDocumentor\\Reflection\\": [
- "src/"
- ]
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Mike van Riel",
- "email": "me@mikevanriel.com"
- }
- ],
- "time": "2017-07-14T14:27:02+00:00"
- },
- {
- "name": "phpspec/prophecy",
- "version": "1.8.0",
- "source": {
- "type": "git",
- "url": "https://github.com/phpspec/prophecy.git",
- "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06",
- "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06",
- "shasum": ""
- },
- "require": {
- "doctrine/instantiator": "^1.0.2",
- "php": "^5.3|^7.0",
- "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0",
- "sebastian/comparator": "^1.1|^2.0|^3.0",
- "sebastian/recursion-context": "^1.0|^2.0|^3.0"
- },
- "require-dev": {
- "phpspec/phpspec": "^2.5|^3.2",
- "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.8.x-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "Prophecy\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Konstantin Kudryashov",
- "email": "ever.zet@gmail.com",
- "homepage": "http://everzet.com"
- },
- {
- "name": "Marcello Duarte",
- "email": "marcello.duarte@gmail.com"
- }
- ],
- "description": "Highly opinionated mocking framework for PHP 5.3+",
- "homepage": "https://github.com/phpspec/prophecy",
- "keywords": [
- "Double",
- "Dummy",
- "fake",
- "mock",
- "spy",
- "stub"
- ],
- "time": "2018-08-05T17:53:17+00:00"
- },
- {
- "name": "phpunit/php-code-coverage",
- "version": "4.0.8",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef7b2f56815df854e66ceaee8ebe9393ae36a40d",
- "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d",
- "shasum": ""
- },
- "require": {
- "ext-dom": "*",
- "ext-xmlwriter": "*",
- "php": "^5.6 || ^7.0",
- "phpunit/php-file-iterator": "^1.3",
- "phpunit/php-text-template": "^1.2",
- "phpunit/php-token-stream": "^1.4.2 || ^2.0",
- "sebastian/code-unit-reverse-lookup": "^1.0",
- "sebastian/environment": "^1.3.2 || ^2.0",
- "sebastian/version": "^1.0 || ^2.0"
- },
- "require-dev": {
- "ext-xdebug": "^2.1.4",
- "phpunit/phpunit": "^5.7"
- },
- "suggest": {
- "ext-xdebug": "^2.5.1"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "4.0.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sb@sebastian-bergmann.de",
- "role": "lead"
- }
- ],
- "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
- "homepage": "https://github.com/sebastianbergmann/php-code-coverage",
- "keywords": [
- "coverage",
- "testing",
- "xunit"
- ],
- "time": "2017-04-02T07:44:40+00:00"
- },
- {
- "name": "phpunit/php-file-iterator",
- "version": "1.4.5",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
- "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4",
- "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.4.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sb@sebastian-bergmann.de",
- "role": "lead"
- }
- ],
- "description": "FilterIterator implementation that filters files based on a list of suffixes.",
- "homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
- "keywords": [
- "filesystem",
- "iterator"
- ],
- "time": "2017-11-27T13:52:08+00:00"
- },
- {
- "name": "phpunit/php-text-template",
- "version": "1.2.1",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-text-template.git",
- "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
- "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "type": "library",
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "Simple template engine.",
- "homepage": "https://github.com/sebastianbergmann/php-text-template/",
- "keywords": [
- "template"
- ],
- "time": "2015-06-21T13:50:34+00:00"
- },
- {
- "name": "phpunit/php-timer",
- "version": "1.0.9",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-timer.git",
- "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f",
- "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f",
- "shasum": ""
- },
- "require": {
- "php": "^5.3.3 || ^7.0"
- },
- "require-dev": {
- "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sb@sebastian-bergmann.de",
- "role": "lead"
- }
- ],
- "description": "Utility class for timing",
- "homepage": "https://github.com/sebastianbergmann/php-timer/",
- "keywords": [
- "timer"
- ],
- "time": "2017-02-26T11:10:40+00:00"
- },
- {
- "name": "phpunit/php-token-stream",
- "version": "2.0.2",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-token-stream.git",
- "reference": "791198a2c6254db10131eecfe8c06670700904db"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db",
- "reference": "791198a2c6254db10131eecfe8c06670700904db",
- "shasum": ""
- },
- "require": {
- "ext-tokenizer": "*",
- "php": "^7.0"
- },
- "require-dev": {
- "phpunit/phpunit": "^6.2.4"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Wrapper around PHP's tokenizer extension.",
- "homepage": "https://github.com/sebastianbergmann/php-token-stream/",
- "keywords": [
- "tokenizer"
- ],
- "time": "2017-11-27T05:48:46+00:00"
- },
- {
- "name": "phpunit/phpunit",
- "version": "5.7.27",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c",
- "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c",
- "shasum": ""
- },
- "require": {
- "ext-dom": "*",
- "ext-json": "*",
- "ext-libxml": "*",
- "ext-mbstring": "*",
- "ext-xml": "*",
- "myclabs/deep-copy": "~1.3",
- "php": "^5.6 || ^7.0",
- "phpspec/prophecy": "^1.6.2",
- "phpunit/php-code-coverage": "^4.0.4",
- "phpunit/php-file-iterator": "~1.4",
- "phpunit/php-text-template": "~1.2",
- "phpunit/php-timer": "^1.0.6",
- "phpunit/phpunit-mock-objects": "^3.2",
- "sebastian/comparator": "^1.2.4",
- "sebastian/diff": "^1.4.3",
- "sebastian/environment": "^1.3.4 || ^2.0",
- "sebastian/exporter": "~2.0",
- "sebastian/global-state": "^1.1",
- "sebastian/object-enumerator": "~2.0",
- "sebastian/resource-operations": "~1.0",
- "sebastian/version": "^1.0.6|^2.0.1",
- "symfony/yaml": "~2.1|~3.0|~4.0"
- },
- "conflict": {
- "phpdocumentor/reflection-docblock": "3.0.2"
- },
- "require-dev": {
- "ext-pdo": "*"
- },
- "suggest": {
- "ext-xdebug": "*",
- "phpunit/php-invoker": "~1.1"
- },
- "bin": [
- "phpunit"
- ],
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "5.7.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "The PHP Unit Testing framework.",
- "homepage": "https://phpunit.de/",
- "keywords": [
- "phpunit",
- "testing",
- "xunit"
- ],
- "time": "2018-02-01T05:50:59+00:00"
- },
- {
- "name": "phpunit/phpunit-mock-objects",
- "version": "3.4.4",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
- "reference": "a23b761686d50a560cc56233b9ecf49597cc9118"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/a23b761686d50a560cc56233b9ecf49597cc9118",
- "reference": "a23b761686d50a560cc56233b9ecf49597cc9118",
- "shasum": ""
- },
- "require": {
- "doctrine/instantiator": "^1.0.2",
- "php": "^5.6 || ^7.0",
- "phpunit/php-text-template": "^1.2",
- "sebastian/exporter": "^1.2 || ^2.0"
- },
- "conflict": {
- "phpunit/phpunit": "<5.4.0"
- },
- "require-dev": {
- "phpunit/phpunit": "^5.4"
- },
- "suggest": {
- "ext-soap": "*"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "3.2.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sb@sebastian-bergmann.de",
- "role": "lead"
- }
- ],
- "description": "Mock Object library for PHPUnit",
- "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
- "keywords": [
- "mock",
- "xunit"
- ],
- "time": "2017-06-30T09:13:00+00:00"
- },
- {
- "name": "sebastian/code-unit-reverse-lookup",
- "version": "1.0.1",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git",
- "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18",
- "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18",
- "shasum": ""
- },
- "require": {
- "php": "^5.6 || ^7.0"
- },
- "require-dev": {
- "phpunit/phpunit": "^5.7 || ^6.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Looks up which function or method a line of code belongs to",
- "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
- "time": "2017-03-04T06:30:41+00:00"
- },
- {
- "name": "sebastian/comparator",
- "version": "1.2.4",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/comparator.git",
- "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be",
- "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3",
- "sebastian/diff": "~1.2",
- "sebastian/exporter": "~1.2 || ~2.0"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.4"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.2.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Jeff Welch",
- "email": "whatthejeff@gmail.com"
- },
- {
- "name": "Volker Dusch",
- "email": "github@wallbash.com"
- },
- {
- "name": "Bernhard Schussek",
- "email": "bschussek@2bepublished.at"
- },
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Provides the functionality to compare PHP values for equality",
- "homepage": "http://www.github.com/sebastianbergmann/comparator",
- "keywords": [
- "comparator",
- "compare",
- "equality"
- ],
- "time": "2017-01-29T09:50:25+00:00"
- },
- {
- "name": "sebastian/diff",
- "version": "1.4.3",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/diff.git",
- "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4",
- "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4",
- "shasum": ""
- },
- "require": {
- "php": "^5.3.3 || ^7.0"
- },
- "require-dev": {
- "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.4-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Kore Nordmann",
- "email": "mail@kore-nordmann.de"
- },
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Diff implementation",
- "homepage": "https://github.com/sebastianbergmann/diff",
- "keywords": [
- "diff"
- ],
- "time": "2017-05-22T07:24:03+00:00"
- },
- {
- "name": "sebastian/environment",
- "version": "2.0.0",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/environment.git",
- "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac",
- "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac",
- "shasum": ""
- },
- "require": {
- "php": "^5.6 || ^7.0"
- },
- "require-dev": {
- "phpunit/phpunit": "^5.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.0.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Provides functionality to handle HHVM/PHP environments",
- "homepage": "http://www.github.com/sebastianbergmann/environment",
- "keywords": [
- "Xdebug",
- "environment",
- "hhvm"
- ],
- "time": "2016-11-26T07:53:53+00:00"
- },
- {
- "name": "sebastian/exporter",
- "version": "2.0.0",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/exporter.git",
- "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4",
- "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3",
- "sebastian/recursion-context": "~2.0"
- },
- "require-dev": {
- "ext-mbstring": "*",
- "phpunit/phpunit": "~4.4"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.0.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Jeff Welch",
- "email": "whatthejeff@gmail.com"
- },
- {
- "name": "Volker Dusch",
- "email": "github@wallbash.com"
- },
- {
- "name": "Bernhard Schussek",
- "email": "bschussek@2bepublished.at"
- },
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- },
- {
- "name": "Adam Harvey",
- "email": "aharvey@php.net"
- }
- ],
- "description": "Provides the functionality to export PHP variables for visualization",
- "homepage": "http://www.github.com/sebastianbergmann/exporter",
- "keywords": [
- "export",
- "exporter"
- ],
- "time": "2016-11-19T08:54:04+00:00"
- },
- {
- "name": "sebastian/global-state",
- "version": "1.1.1",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/global-state.git",
- "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4",
- "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.2"
- },
- "suggest": {
- "ext-uopz": "*"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Snapshotting of global state",
- "homepage": "http://www.github.com/sebastianbergmann/global-state",
- "keywords": [
- "global state"
- ],
- "time": "2015-10-12T03:26:01+00:00"
- },
- {
- "name": "sebastian/object-enumerator",
- "version": "2.0.1",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/object-enumerator.git",
- "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7",
- "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7",
- "shasum": ""
- },
- "require": {
- "php": ">=5.6",
- "sebastian/recursion-context": "~2.0"
- },
- "require-dev": {
- "phpunit/phpunit": "~5"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.0.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Traverses array structures and object graphs to enumerate all referenced objects",
- "homepage": "https://github.com/sebastianbergmann/object-enumerator/",
- "time": "2017-02-18T15:18:39+00:00"
- },
- {
- "name": "sebastian/recursion-context",
- "version": "2.0.0",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/recursion-context.git",
- "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a",
- "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.4"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.0.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Jeff Welch",
- "email": "whatthejeff@gmail.com"
- },
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- },
- {
- "name": "Adam Harvey",
- "email": "aharvey@php.net"
- }
- ],
- "description": "Provides functionality to recursively process PHP variables",
- "homepage": "http://www.github.com/sebastianbergmann/recursion-context",
- "time": "2016-11-19T07:33:16+00:00"
- },
- {
- "name": "sebastian/resource-operations",
- "version": "1.0.0",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/resource-operations.git",
- "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52",
- "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52",
- "shasum": ""
- },
- "require": {
- "php": ">=5.6.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Provides a list of PHP built-in functions that operate on resources",
- "homepage": "https://www.github.com/sebastianbergmann/resource-operations",
- "time": "2015-07-28T20:34:47+00:00"
- },
- {
- "name": "sebastian/version",
- "version": "2.0.1",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/version.git",
- "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019",
- "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019",
- "shasum": ""
- },
- "require": {
- "php": ">=5.6"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.0.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "Library that helps with managing the version number of Git-hosted PHP projects",
- "homepage": "https://github.com/sebastianbergmann/version",
- "time": "2016-10-03T07:35:21+00:00"
- },
- {
- "name": "symfony/polyfill-ctype",
- "version": "v1.9.0",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-ctype.git",
- "reference": "e3d826245268269cd66f8326bd8bc066687b4a19"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19",
- "reference": "e3d826245268269cd66f8326bd8bc066687b4a19",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "suggest": {
- "ext-ctype": "For best performance"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.9-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Symfony\\Polyfill\\Ctype\\": ""
- },
- "files": [
- "bootstrap.php"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- },
- {
- "name": "Gert de Pagter",
- "email": "BackEndTea@gmail.com"
- }
- ],
- "description": "Symfony polyfill for ctype functions",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "ctype",
- "polyfill",
- "portable"
- ],
- "time": "2018-08-06T14:22:27+00:00"
- },
- {
- "name": "symfony/yaml",
- "version": "v4.1.3",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/yaml.git",
- "reference": "46bc69aa91fc4ab78a96ce67873a6b0c148fd48c"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/yaml/zipball/46bc69aa91fc4ab78a96ce67873a6b0c148fd48c",
- "reference": "46bc69aa91fc4ab78a96ce67873a6b0c148fd48c",
- "shasum": ""
- },
- "require": {
- "php": "^7.1.3",
- "symfony/polyfill-ctype": "~1.8"
- },
- "conflict": {
- "symfony/console": "<3.4"
- },
- "require-dev": {
- "symfony/console": "~3.4|~4.0"
- },
- "suggest": {
- "symfony/console": "For validating YAML files using the lint command"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "4.1-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Symfony\\Component\\Yaml\\": ""
- },
- "exclude-from-classmap": [
- "/Tests/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony Yaml Component",
- "homepage": "https://symfony.com",
- "time": "2018-07-26T11:24:31+00:00"
- },
- {
- "name": "webmozart/assert",
- "version": "1.3.0",
- "source": {
- "type": "git",
- "url": "https://github.com/webmozart/assert.git",
- "reference": "0df1908962e7a3071564e857d86874dad1ef204a"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a",
- "reference": "0df1908962e7a3071564e857d86874dad1ef204a",
- "shasum": ""
- },
- "require": {
- "php": "^5.3.3 || ^7.0"
- },
- "require-dev": {
- "phpunit/phpunit": "^4.6",
- "sebastian/version": "^1.0.1"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.3-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Webmozart\\Assert\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Bernhard Schussek",
- "email": "bschussek@gmail.com"
- }
- ],
- "description": "Assertions to validate method input/output with nice error messages.",
- "keywords": [
- "assert",
- "check",
- "validate"
- ],
- "time": "2018-01-29T19:49:41+00:00"
- }
- ],
- "aliases": [],
- "minimum-stability": "stable",
- "stability-flags": [],
- "prefer-stable": false,
- "prefer-lowest": false,
- "platform": {
- "php": "7.*",
- "ext-ctype": "*",
- "ext-mbstring": "*"
- },
- "platform-dev": []
-}
diff --git a/phpunit.xml b/phpunit.xml
deleted file mode 100644
index 8c26e40..0000000
--- a/phpunit.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-## Authors, Contributors
-
-Name | GitHub user
---- | ---
-David Belicza | @DavidBelicza
-Riccardo Marton | @riccardomarton
-Syndesi | @Syndesi
-vincentsch | @vincentsch
-Andrew Welch | @khalwat
-Andrey Astashov | @mvcaaa
-Leo Toneff | @bragle
-
-## TextRank or Automatic summarization
-> Automatic summarization is the process of reducing a text document with a computer program in order to create a summary that retains the most important points of the original document. Technologies that can make a coherent summary take into account variables such as length, writing style and syntax. Automatic data summarization is part of machine learning and data mining. The main idea of summarization is to find a representative subset of the data, which contains the information of the entire set. Summarization technologies are used in a large number of sectors in industry today. - Wikipedia
-
-The algorithm of this implementation is:
-* Find sentences,
-* Remove stopwords,
-* Create integer values by find and count the matching words,
-* Change the integer values by the related words' integer values,
-* Normalize values to create scores,
-* Order by scores
-
-## Install
-```
-composer require php-science/textrank
-```
-
-## Test
-```
-cd project-folder
-composer test
-```
-or
-```
-cd project-folder
-phpunit --colors='always' $(pwd)/tests
-```
-
-## Examples
-```php
-
-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);
-```
-More examples: https://github.com/DoveID/PHP-Science-TextRank/blob/master/tests/TextRankFacadeTest.php
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+This source code is an OOP implementation of the TextRank algorithm.
+
The minimum required PHP version is 7.4.
+
+
+
- * array(
- * 'apple' => array( // word
- * 2 => array( // ID of the sentence
- * 52 => array( // ID of the word in the sentence
- * 51, 53 // IDs of the closest words to the apple word
- * ),
- * 10 => array( // IDs of the closest words to the apple word
- * 9, 11 // IDs of the closest words to the apple word
- * ),
- * 5 => array(6)
- * ),
- * 6 => array(
- * 9 => array(8, 10)
- * ),
- * ),
- * 'orange' => array(
- * 1 => array(
- * 30 => array(29, 31)
- * )
- * )
- * );
- *
- *
- * @return array
- */
- public function getGraph(): array
- {
- return $this->graph;
- }
-}
diff --git a/src/Tool/Parser.php b/src/Tool/Parser.php
deleted file mode 100644
index 76829be..0000000
--- a/src/Tool/Parser.php
+++ /dev/null
@@ -1,213 +0,0 @@
-minimumWordLength = $wordLength;
- }
-
- /**
- * It sets the raw text.
- *
- * @param string $rawText
- */
- public function setRawText(string $rawText)
- {
- $this->rawText = $rawText;
- }
-
- /**
- * Set Stop Words.
- *
- * It sets the stop words to remove them from the found keywords.
- *
- * @param StopWordsAbstract $words Stop Words to ignore. These words will
- * not be keywords.
- */
- public function setStopWords(StopWordsAbstract $words)
- {
- $this->stopWords = $words;
- }
-
- /**
- * It retrieves the punctuations.
- *
- * @return array Array from punctuations where key is the index to link to
- * the sentence and value is the punctuation.
- */
- public function getMarks(): array
- {
- return $this->marks;
- }
-
- /**
- * Parse.
- *
- * It parses the text from the property and retrieves in Text object
- * prepared to scoring and to searching.
- *
- * @return Text Parsed text prepared to scoring.
- */
- public function parse(): Text
- {
- $matrix = [];
- $sentences = $this->getSentences();
-
- foreach ($sentences as $sentenceIdx => $sentence) {
- $matrix[$sentenceIdx] = $this->getWords($sentence);
- }
-
- $text = new Text();
- $text->setSentences($sentences);
- $text->setWordMatrix($matrix);
- $text->setMarks($this->marks);
-
- return $text;
- }
-
- /**
- * Sentences.
- *
- * It retrieves the sentences in array without junk data.
- *
- * @return array Array from sentences.
- */
- protected function getSentences(): array
- {
- $sentences = $sentences = preg_split(
- '/(\n+)|(\.\s|\?\s|\!\s)(?![^\(]*\))/',
- $this->rawText,
- -1,
- PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE
- );
-
- return array_values(
- array_filter(
- array_map(
- [$this, 'cleanSentence'],
- $sentences
- )
- )
- );
- }
-
- /**
- * Possible Keywords.
- *
- * It retrieves an array of possible keywords without junk characters,
- * spaces and stop words.
- *
- * @param string $subText It should be a sentence.
- *
- * @return array The array of the possible keywords.
- */
- protected function getWords(string $subText): array
- {
- $words = preg_split(
- '/(?:(^\p{P}+)|(\p{P}*\s+\p{P}*)|(\p{P}+$))/',
- $subText,
- -1,
- PREG_SPLIT_NO_EMPTY
- );
-
- $words = array_values(
- array_filter(
- array_map(
- [$this, 'cleanWord'],
- $words
- )
- )
- );
-
- if ($this->stopWords) {
- return array_filter($words, function($word) {
- return !ctype_punct($word)
- && strlen($word) > $this->minimumWordLength
- && !$this->stopWords->exist($word);
- });
- } else {
- return array_filter($words, function($word) {
- return !ctype_punct($word)
- && strlen($word) > $this->minimumWordLength;
- });
- }
- }
-
- /**
- * Clean Sentence.
- *
- * It clean the sentence. If it is a punctuation it will be stored in the
- * property $marks.
- *
- * @param string $sentence A sentence as a string.
- *
- * @return string It is empty string when it's punctuation. Otherwise it's
- * the trimmed sentence itself.
- */
- protected function cleanSentence(string $sentence): string
- {
- if (strlen(trim($sentence)) == 1) {
- $this->marks[] = trim($sentence);
- return '';
-
- } else {
- return trim($sentence);
- }
- }
-
- /**
- * Clean Word.
- *
- * It removes the junk spaces from the word and retrieves it.
- *
- * @param string $word
- *
- * @return string Cleaned word.
- */
- protected function cleanWord(string $word): string
- {
- return mb_strtolower(trim($word));
- }
-}
diff --git a/src/Tool/Score.php b/src/Tool/Score.php
deleted file mode 100644
index f28b2c3..0000000
--- a/src/Tool/Score.php
+++ /dev/null
@@ -1,176 +0,0 @@
-getGraph();
- $wordMatrix = $text->getWordMatrix();
- $wordConnections = $this->calculateConnectionNumbers($graphData);
- $scores = $this->calculateScores(
- $graphData,
- $wordMatrix,
- $wordConnections
- );
-
- return $this->normalizeAndSortScores($scores);
- }
-
- /**
- * Connection Numbers.
- *
- * It calculates the number of connections for each word and retrieves it
- * in array where key is the word and value is the number of connections.
- *
- * @param array $graphData Graph data from a Graph type object.
- *
- * @return array Key is the word and value is the number of the connected
- * words.
- */
- protected function calculateConnectionNumbers(array &$graphData): array
- {
- $wordConnections = [];
-
- foreach ($graphData as $wordKey => $sentences) {
- $connectionCount = 0;
-
- foreach ($sentences as $sentenceIdx => $wordInstances) {
- foreach ($wordInstances as $connections) {
- $connectionCount += count($connections);
- }
- }
-
- $wordConnections[$wordKey] = $connectionCount;
- }
-
- return $wordConnections;
- }
-
- /**
- * Calculate Scores.
- *
- * It calculates the score of the words and retrieves it in array where key
- * is the word and value is the score. The score depends on the number of
- * the connections and the closest word's connection numbers.
- *
- * @param array $graphData Graph data from a Graph type object.
- * @param array $wordMatrix Multidimensional array from integer keys
- * and string values.
- * @param array $wordConnections Key is the word and value is the number of
- * the connected words.
- *
- * @return array Scores where key is the word and value is the score.
- */
- protected function calculateScores(
- array &$graphData,
- array &$wordMatrix,
- array &$wordConnections
- ): array {
- $scores = [];
-
- foreach ($graphData as $wordKey => $sentences) {
- $value = 0;
-
- foreach ($sentences as $sentenceIdx => $wordInstances) {
- foreach ($wordInstances as $connections) {
- foreach ($connections as $wordIdx) {
- $word = $wordMatrix[$sentenceIdx][$wordIdx];
- $value += $wordConnections[$word];
- }
- }
- }
-
- $scores[$wordKey] = $value;
-
- if ($value > $this->maximumValue) {
- $this->maximumValue = $value;
- }
-
- if ($value < $this->minimumValue || $this->minimumValue == 0) {
- $this->minimumValue = $value;
- }
- }
-
- return $scores;
- }
-
- /**
- * Normalize and Sort Scores.
- *
- * It recalculates the scores by normalize the score numbers to between 0
- * and 1.
- *
- * @param array $scores Keywords with scores. Score is the key.
- *
- * @return array Keywords with normalized and ordered scores.
- */
- protected function normalizeAndSortScores(array &$scores): array
- {
- foreach ($scores as $key => $value) {
- $v = $this->normalize(
- $value,
- $this->minimumValue,
- $this->maximumValue
- );
-
- $scores[$key] = $v;
- }
-
- arsort($scores);
-
- return $scores;
- }
-
- /**
- * It normalizes a number.
- *
- * @param int $value Current weight.
- * @param int $min Minimum weight.
- * @param int $max Maximum weight.
- *
- * @return float|int Normalized weight aka score.
- */
- protected function normalize(int $value, int $min, int $max): float
- {
- $divisor = $max - $min;
-
- if ($divisor == 0) {
- return 0.0;
- }
-
- $normalized = ($value - $min) / $divisor;
-
- return $normalized;
- }
-}
diff --git a/src/Tool/StopWords/English.php b/src/Tool/StopWords/English.php
deleted file mode 100644
index 4b08b8b..0000000
--- a/src/Tool/StopWords/English.php
+++ /dev/null
@@ -1,334 +0,0 @@
-words) !== false;
- }
-}
diff --git a/src/Tool/Summarize.php b/src/Tool/Summarize.php
deleted file mode 100644
index fd4fed4..0000000
--- a/src/Tool/Summarize.php
+++ /dev/null
@@ -1,224 +0,0 @@
-getGraph();
- $sentences = $text->getSentences();
- $marks = $text->getMarks();
- $this->findAndWeightSentences($scores, $graphData, $keyWordLimit);
-
- if ($type == Summarize::GET_ALL_IMPORTANT) {
- return $this->getAllImportant($sentences, $marks, $sentenceLimit);
-
- } else if ($type == Summarize::GET_FIRST_IMPORTANT_AND_FOLLOWINGS) {
- return $this->getFirstImportantAndFollowings(
- $sentences,
- $marks,
- $sentenceLimit
- );
- }
-
- return [];
- }
-
- /**
- * Find and Weight Sentences.
- *
- * It finds the most important sentences and stores them into the property.
- *
- * @param array $scores Keywords with scores. Score is the key.
- * @param array $graphData Graph data from a Graph type object.
- * @param int $keyWordLimit How many keyword should be used to find the
- * important sentences.
- */
- protected function findAndWeightSentences(
- array &$scores,
- array &$graphData,
- int $keyWordLimit
- ) {
- $i = 0;
-
- foreach ($scores as $word => $score) {
- if ($i >= $keyWordLimit) {
- break;
- }
-
- $i++;
- $wordMap = $graphData[$word];
-
- foreach ($wordMap as $key => $value) {
- $this->updateSentenceWeight($key);
- }
- }
-
- arsort($this->sentenceWeight);
- }
-
- /**
- * Important Sentences.
- *
- * It retrieves the important sentences.
- *
- * @param array $sentences Sentences, ordered by weights.
- * @param array $marks Array of punctuations. Key is the reference
- * to the sentence, value is the punctuation.
- * @param int $sentenceLimit How many sentence should be retrieved.
- *
- * @return array An array from sentences what are the most important
- * sentences.
- */
- protected function getAllImportant(
- array &$sentences,
- array &$marks,
- int $sentenceLimit
- ): array {
-
- $summary = [];
- $i = 0;
-
- foreach ($this->sentenceWeight as $sentenceIdx => $weight) {
- if ($i >= $sentenceLimit) {
- break;
- }
-
- $i++;
- $summary[$sentenceIdx] = $sentences[$sentenceIdx]
- . $this->getMark($marks, $sentenceIdx);
- }
-
- ksort($summary);
-
- return $summary;
- }
-
- /**
- * Most Important Sentence and Next.
- *
- * It retrieves the first most important sentence and its following
- * sentences.
- *
- * @param array $sentences Sentences, ordered by weights.
- * @param array $marks Array of punctuations. Key is the reference
- * to the sentence, value is the punctuation.
- * @param int $sentenceLimit How many sentence should be retrieved.
- *
- * @return array An array from sentences what contains the most important
- * sentence and its following sentences.
- */
- protected function getFirstImportantAndFollowings(
- array &$sentences,
- array &$marks,
- int $sentenceLimit
- ): array {
-
- $summary = [];
- $startIdx = 0;
-
- foreach ($this->sentenceWeight as $sentenceIdx => $weight) {
- $summary[$sentenceIdx] = $sentences[$sentenceIdx] .
- $this->getMark($marks, $sentenceIdx);
-
- $startIdx = $sentenceIdx;
- break;
- }
-
- $i = 0;
-
- foreach ($sentences as $sentenceIdx => $sentence) {
- if ($sentenceIdx <= $startIdx) {
- continue;
- } else if ($i >= $sentenceLimit - 1) {
- break;
- }
-
- $i++;
- $summary[$sentenceIdx] = $sentences[$sentenceIdx] .
- $this->getMark($marks, $sentenceIdx);
- }
-
- return $summary;
- }
-
- /**
- * Update Sentence Weight.
- *
- * It updates the sentence weight what is stored in the property.
- *
- * @param int $sentenceIdx Index of the sentence.
- */
- protected function updateSentenceWeight(int $sentenceIdx)
- {
- if (isset($this->sentenceWeight[$sentenceIdx])) {
- $this->sentenceWeight[$sentenceIdx] = $this->sentenceWeight[$sentenceIdx] + 1;
- } else {
- $this->sentenceWeight[$sentenceIdx] = 1;
- }
- }
-
- /**
- * Punctuations.
- *
- * It retrieves the punctuation of the sentence.
- *
- * @param array $marks The punctuation. Key is the reference to the
- * sentence, value is the punctuation.
- * @param int $idx Key of the punctuation.
- *
- * @return string The punctuation of the sentence.
- */
- protected function getMark(array &$marks, int $idx)
- {
- return isset($marks[$idx]) ? $marks[$idx] : '';
- }
-}
diff --git a/src/Tool/Text.php b/src/Tool/Text.php
deleted file mode 100644
index 458fc04..0000000
--- a/src/Tool/Text.php
+++ /dev/null
@@ -1,99 +0,0 @@
-wordMatrix = $wordMatrix;
- }
-
- /**
- * It sets the sentences.
- *
- * @param array $sentences Array's key should be an int and value should be
- * string.
- */
- public function setSentences(array $sentences)
- {
- $this->sentences = $sentences;
- }
-
- /**
- * It set the punctuations to the property.
- *
- * @param array $marks Array's key should be an int and value should be
- * string.
- */
- public function setMarks(array $marks)
- {
- $this->marks = $marks;
- }
-
- /**
- * It retrieves the words in sentence groups.
- *
- * @return array Multidimensional array from words of the text. Key is
- * index of the sentence, value is an array from words
- * where key is the index of the word and value is the word.
- */
- public function getWordMatrix(): array
- {
- return $this->wordMatrix;
- }
-
- /**
- * It retrieves the sentences.
- *
- * @return array Array from sentences where key is the index and value is
- * the sentence.
- */
- public function getSentences(): array
- {
- return $this->sentences;
- }
-
- /**
- * It retrieves the punctuations.
- *
- * @return array Array from punctuations where key is the index to link to
- * the sentence and value is the punctuation.
- */
- public function getMarks(): array
- {
- return $this->marks;
- }
-}
diff --git a/tests/functional/TextRankFacadeTest.php b/tests/functional/TextRankFacadeTest.php
deleted file mode 100644
index 41151ac..0000000
--- a/tests/functional/TextRankFacadeTest.php
+++ /dev/null
@@ -1,151 +0,0 @@
-sampleText1 = fread($file, filesize($path));
-
- fclose($file);
- }
-
- public function testGetOnlyKeyWords()
- {
- $api = new TextRankFacade();
- $stopWords = new English();
- $api->setStopWords($stopWords);
-
- $result = $api->getOnlyKeyWords($this->sampleText1);
-
- $this->assertTrue(count($result) > 0);
- $this->assertTrue(array_values($result)[0] == 1);
- }
-
- public function testGetHighlights()
- {
- $api = new TextRankFacade();
- $stopWords = new English();
- $api->setStopWords($stopWords);
-
- $result = $api->getHighlights($this->sampleText1);
-
- $this->assertTrue(count($result) > 0);
- }
-
- public function testSummarizeTextCompound()
- {
- $api = new TextRankFacade();
- $stopWords = new English();
- $api->setStopWords($stopWords);
-
- $result = $api->summarizeTextCompound($this->sampleText1);
-
- $this->assertTrue(count($result) > 0);
- }
-
- public function testSummarizeTextBasic()
- {
- $api = new TextRankFacade();
- $stopWords = new English();
- $api->setStopWords($stopWords);
-
- $result = $api->summarizeTextBasic($this->sampleText1);
-
- $this->assertTrue(count($result) > 0);
- }
-
- public function testSummarizeTextFreely()
- {
- $api = new TextRankFacade();
- $stopWords = new English();
- $api->setStopWords($stopWords);
-
- $result = $api->summarizeTextFreely(
- $this->sampleText1,
- 5,
- 2,
- Summarize::GET_ALL_IMPORTANT
- );
-
- $this->assertTrue(count($result) == 2);
-
- $result = $api->summarizeTextFreely(
- $this->sampleText1,
- 10,
- 1,
- Summarize::GET_FIRST_IMPORTANT_AND_FOLLOWINGS
- );
-
- $this->assertTrue(count($result) == 1);
-
- // Stop words.
- $result = $api->summarizeTextFreely(
- 'one two. one two. three four.',
- 2,
- 10,
- Summarize::GET_ALL_IMPORTANT
- );
-
- $this->assertTrue(count($result) == 0);
-
- // Less sentences then expected.
- $result = $api->summarizeTextFreely(
- 'lorem ipsum. lorem holy ipsum. sit dolor amet.',
- 2,
- 10,
- Summarize::GET_ALL_IMPORTANT
- );
-
- $this->assertTrue(count($result) == 2);
- }
-
- public function testSmallText()
- {
- $api = new TextRankFacade();
- $stopWords = new English();
- $api->setStopWords($stopWords);
-
- $result = $api->getOnlyKeyWords('lorem ipsum sit');
-
- $this->assertEquals(2, count($result));
-
- $result = $api->getOnlyKeyWords('sit');
-
- $this->assertEquals(0, count($result));
-
- $result = $api->getOnlyKeyWords('');
-
- $this->assertEquals(0, count($result));
- }
-
- public function testSmallTextRu()
- {
- $api = new TextRankFacade();
- $stopWords = new Russian();
- $api->setStopWords($stopWords);
- $result = $api->getOnlyKeyWords('между холодными ладонями');
- $this->assertCount(2, $result);
-
- $result = $api->getOnlyKeyWords('конец');
- $this->assertCount(0, $result);
-
- $result = $api->getOnlyKeyWords('');
- $this->assertCount(0, $result);
- }
-}