Skip to content

Added data strict data type, upgraded dependencies #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
-
package-ecosystem: composer
directory: "/"
schedule:
interval: weekly
versioning-strategy: auto
groups:
dev-dependencies:
dependency-type: "development"
81 changes: 81 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# GithHub Actions Workflow generated with Ghygen
# Original configuration: https://ghygen.hi-folks.dev?code=0555902844da5dd5163a69e93327a0aa
name: PHP NLP Tools
on:
push:
branches:
- master
- main
- develop
pull_request:
branches:
- master
- main
- develop

jobs:
tests:
runs-on: ubuntu-latest

strategy:
matrix:
operating-system: [ ubuntu-latest ]
php: [ '8.1', '8.2', '8.3' ]
dependency-stability: [ 'prefer-stable' ]

name: PHP ${{ matrix.php }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install PHP versions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: gd

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache Composer dependencies
uses: actions/cache@v4
id: actions-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Cache PHP dependencies (vendor)
uses: actions/cache@v4
id: vendor-cache
with:
path: vendor
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}

- name: Install Dependencies
if: steps.vendor-cache.outputs.cache-hit != 'true'
run: |
composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction --no-suggest

- name: Update Dependencies with latest stable
if: matrix.dependency-stability == 'prefer-stable'
run: composer update --prefer-stable

# Code quality
- name: Execute Code Sniffer
run: vendor/bin/phpcs

- name: Execute PHP Stan
run: vendor/bin/phpstan

- name: Execute Rector
run: vendor/bin/rector --dry-run

- name: Execute PHP Unit
run: vendor/bin/phpunit --exclude-group Slow


7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor/
/nbproject/private/
nbproject
/vendor/
/composer.lock
/.phpunit.result.cache

28 changes: 27 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[PHP NlpTools](http://php-nlp-tools.com/)
=============

NlpTools is a set of php 5.3+ classes for beginner to
NlpTools is a set of php 8.1+ classes for beginner to
semi advanced natural language processing work.

Documentation
Expand Down Expand Up @@ -92,3 +92,29 @@ Lda is still experimental and quite slow but it works. [See an example](http://p
2. Stop words
3. Language based normalizers
4. Classifier based transformation for creating flexible preprocessing pipelines

Testing information
===================


Writing Tests
-------------

* Test classes should be in the same namespace as the class that is being tested
* Any data needed for the test or produced by the test should be in the 'data' directory
under the same folder as the namespace. Only data needed (not produced) are commited to
the repository.
* Tests should be marked with the groups **Slow** and **VerySlow** if they require more than
10 seconds and 1 minute respectively. If a test is marked as VerySlow it should also be marked
as Slow.
* Both functional and unit tests are welcome.

Executing Tests
---------------

Currently only one testsuite is defined (all tests). Because some tests take a long time to
run you can try running `phpunit --exclude-group Slow` or `phpunit --exclude-group VerySlow`
to avoid some slow tests.

PHPUnit should be run from inside the tests folder or the phpunit.xml file should be provided
as config.
48 changes: 25 additions & 23 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
{
"name": "nlp-tools/nlp-tools",
"description": "NlpTools is a set of php 5.3+ classes for beginner to semi advanced natural language processing work.",
"keywords": ["nlp","machine learning"],
"license": "WTFPL",
"authors": [
{
"name": "Angelos Katharopoulos",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.3"
},
"autoload": {
"psr-0": {
"NlpTools\\": "src/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
}
"name": "nlp-tools/nlp-tools",
"description": "NlpTools is a set of php 8.1+ classes for beginner to semi advanced natural language processing work.",
"keywords": ["nlp","machine learning"],
"license": "WTFPL",
"authors": [
{
"name": "Angelos Katharopoulos",
"email": "[email protected]"
}
],
"require": {
"php": ">=8.1",
"ext-gd": "*"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.10",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.0 || ^11.0",
"rector/rector": "^1.0"
},
"autoload": {
"psr-0": {
"NlpTools\\": "src/"
}
}
}
24 changes: 24 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="phpcs.xsd">
<description>The coding standard.</description>

<config name="testVersion" value="8.0-"/>

<file>src</file>
<file>tests</file>
<exclude-pattern>*/tests/sentiment_maxent.php</exclude-pattern>

<arg name="basepath" value="./"/>
<arg name="colors"/>
<arg name="parallel" value="5"/>
<arg value="np"/>

<!-- Don't hide tokenizer exceptions -->
<rule ref="Internal.Tokenizer.Exception">
<type>error</type>
</rule>

<!-- Include the whole PSR12 standard -->
<rule ref="PSR12"/>

</ruleset>
8 changes: 8 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
parameters:
paths:
- ./src
- ./tests
excludePaths:
- ./tests/sentiment_maxent.php
# The level 9 is the highest level (with check for mixed type)
level: 6
5 changes: 5 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<phpunit bootstrap="tests/bootstrap.php" colors="true">
<testsuite name="NlpTools" >
<directory>./tests/NlpTools/</directory>
</testsuite>
</phpunit>
51 changes: 51 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
use Rector\Visibility\Rector\ClassConst\ChangeConstantVisibilityRector;
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector;
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
use Rector\CodingStyle\Rector\FuncCall\StrictArraySearchRector;
use Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector;
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;
use Rector\PHPUnit\Set\PHPUnitSetList;

return RectorConfig::configure()
->withPaths([
__DIR__.'/src',
__DIR__.'/tests',
])
// uncomment to reach your current PHP version
->withPhpSets()
->withRules([
AddVoidReturnTypeWhereNoReturnRector::class,
ChangeConstantVisibilityRector::class,
RenameForeachValueVariableToMatchExprVariableRector::class,
ReturnTypeFromReturnNewRector::class,
CountArrayToEmptyArrayComparisonRector::class,
StrictArraySearchRector::class,
SymplifyQuoteEscapeRector::class,
DeclareStrictTypesRector::class,
])
->withSets([
PHPUnitSetList::PHPUNIT_110,
])
->withPhpSets()
->withPHPStanConfigs(['phpstan.neon'])
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
privatization: true,
naming: true,
instanceOf: true,
earlyReturn: true,
strictBooleans: true
)
->withSkip([
__DIR__ . '/tests/sentiment_maxent.php'
]);
Loading