I use your examples but it does not work
marn65 opened this issue · 4 comments
hi.I was looking for a text mining code in python and I saw this awesome php code.
I installed package in ubuntu 16.04.3:
sudo apt-get install libpspell-dev php7.0-pspell aspell-en php7.0-enchant
then I used composer install. after it finished I went to test folder:
gn@me ~/c/p/tests> php TestBaseCase.php
PHP Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /home/gn/code/php-text-analysis/tests/TestBaseCase.php on line 13
also I used tokenizer as bellow:
<?php
use TextAnalysis\Tokenizers\GeneralTokenizer;
$tokenizer = new GeneralTokenizer();
$text1 = $tokenizer->tokenize('hi, how are you');
$text2 = $tokenizer->tokenize('hello, thank you') ;
and it returned:
gn@me ~/c/p/tests> php similarity.php
PHP Fatal error: Uncaught Error: Class 'TextAnalysis\Tokenizers\GeneralTokenizer' not found in /home/gn/code/php-text-analysis/tests/similarity.php:6
Stack trace:
#0 {main}
thrown in /home/gn/code/php-text-analysis/tests/similarity.php on line 6
also, I went to src folder and created a similarity.php file:
<?php
require_once 'Tokenizers/GeneralTokenizer.php';
$tokenizer = new \Tokenizers\GeneralTokenizer();
$text1 = $tokenizer->tokenize('hi, how are you');
$text2 = $tokenizer->tokenize('hello, thank you') ;
and it gaves me this error:
PHP Fatal error: Class 'TextAnalysis\Tokenizers\TokenizerAbstract' not found in /home/gn/code/php-text-analysis/src/Tokenizers/GeneralTokenizer.php on line 11
what is my wrong steps and how can I use code correctly?
thanks
I had the same issue in my code!
Are you using composer to manage your project's dependencies?
I used composer require yooper/php-text-analysis
then in the /home/m/code/sim/vendor/yooper/php-text-analysis/src
folder created this php file:
<?php
require_once 'Tokenizers/GeneralTokenizer.php';
$tokenizer = new \Tokenizers\GeneralTokenizer();
$text1 = $tokenizer->tokenize('hi, how are you');
$text2 = $tokenizer->tokenize('hello, thank you') ;
and the output is:
m@rn ~/c/s/v/y/p/src> php thread.php
PHP Fatal error: Class 'TextAnalysis\Tokenizers\TokenizerAbstract' not found in /home/m/code/sim/vendor/yooper/php-text-analysis/src/Tokenizers/GeneralTokenizer.php on line 11
This isn't an issue with the library. It is an issue with loading the required class files. That is outside the scope for me to answer. Please read http://php.net/manual/en/language.oop5.autoload.php to get a better understanding how an autoloader works.