Tags
Asked 1 years ago
8 Mar 2023
Views 186
debugger

debugger posted

use class not found php


i am stuck with namespace related thing in php
here is the code
i installed php code by composer and now try to use it :

 use phpscience\TextRank\Tool\StopWords\English;

// String contains a long text, see the /res/sample1.txt file.
$text = "Lorem ipsum...";

$api = new TextRankFacade();


but i am getting following error :
Fatal error: Uncaught Error: Class 'TextRankFacade' not found

answered Mar 8 '23 00:00

try to generate autoload file if there is not exit by this command :

composer dumpautoload


not sure it solve your problem or not
jessica

jessica
answered Mar 8 '23 00:00

sample code
index.php - if index.php is at upper level vendor folder


<?php 
require "vendor/autoload.php";

use PhpScience\TextRank\Tool\StopWords\English;

// String contains a long text, see the /res/sample1.txt file.
$text = "Lorem ipsum...";

$api = new PhpScience\TextRank\TextRankFacade();
// English implementation for stopwords/junk words:
$stopWords = new English();
$api->setStopWords($stopWords);

// Array of the most important keywords:
$result = $api->getOnlyKeyWords($text); 
print_r($result);
// Array of the sentences from the most important part of the text:
$result = $api->getHighlights($text); 
print_r($result);
// Array of the most important sentences from the text:
$result = $api->summarizeTextBasic($text);
print_r($result);
?>


include the autoload.php at first and use the class as per need
Post Answer