reco4php icon indicating copy to clipboard operation
reco4php copied to clipboard

How can I use it?

Open prashantidealittechno opened this issue 10 years ago • 0 comments

Hello I am getting below error on running the codes.

Fatal error: Uncaught Error: Class 'GraphAware\Reco4PHP\Demo\Github\RecommendationEngine' not found in /var/www/html/recommendation_2/example.php:9 Stack trace: #0 {main} thrown in /var/www/html/recommendation_2/example.php on line 9

php7.0.8 neo4j 3.x.x composer installed and run composer update command. I also installed the test data given in readme.

My codes on example.php

<?php

require_once __DIR__.'/vendor/autoload.php';

use GraphAware\Reco4PHP\Demo\Github\RecommendationEngine;
use GraphAware\Reco4PHP\RecommenderService;

$rs = RecommenderService::create("http://neo4j:neo4j@localhost:7474");
$rs->registerRecommendationEngine(new RecommendationEngine());

$stopwatch = new \Symfony\Component\Stopwatch\Stopwatch();

$input = $rs->findInputBy('User', 'login', 'jakzal');

$engine = $rs->getRecommender("github_who_to_follow");

$stopwatch->start('reco');
$recommendations = $engine->recommend($input);
$e = $stopwatch->stop('reco');

//echo $recommendations->size() . ' found in ' . $e->getDuration() .  'ms' .PHP_EOL;

foreach ($recommendations->getItems(10) as $reco) {
    echo $reco->item()->get('login') . PHP_EOL;
    echo $reco->totalScore() . PHP_EOL;
    foreach ($reco->getScores() as $name => $score) {
        echo "\t" . $name . ':' . $score->score() . PHP_EOL;
    }
}

prashantidealittechno avatar Aug 10 '16 07:08 prashantidealittechno