• <small id='BA6IQ'></small><noframes id='BA6IQ'>

    <i id='BA6IQ'><tr id='BA6IQ'><dt id='BA6IQ'><q id='BA6IQ'><span id='BA6IQ'><b id='BA6IQ'><form id='BA6IQ'><ins id='BA6IQ'></ins><ul id='BA6IQ'></ul><sub id='BA6IQ'></sub></form><legend id='BA6IQ'></legend><bdo id='BA6IQ'><pre id='BA6IQ'><center id='BA6IQ'></center></pre></bdo></b><th id='BA6IQ'></th></span></q></dt></tr></i><div id='BA6IQ'><tfoot id='BA6IQ'></tfoot><dl id='BA6IQ'><fieldset id='BA6IQ'></fieldset></dl></div>
    <legend id='BA6IQ'><style id='BA6IQ'><dir id='BA6IQ'><q id='BA6IQ'></q></dir></style></legend>

      • <bdo id='BA6IQ'></bdo><ul id='BA6IQ'></ul>

        <tfoot id='BA6IQ'></tfoot>

        Neo4j - Graphaware reco4php - 命名空间问题

        时间:2023-10-03
        <legend id='IKDQd'><style id='IKDQd'><dir id='IKDQd'><q id='IKDQd'></q></dir></style></legend>
        • <small id='IKDQd'></small><noframes id='IKDQd'>

            <tbody id='IKDQd'></tbody>

          1. <tfoot id='IKDQd'></tfoot>

          2. <i id='IKDQd'><tr id='IKDQd'><dt id='IKDQd'><q id='IKDQd'><span id='IKDQd'><b id='IKDQd'><form id='IKDQd'><ins id='IKDQd'></ins><ul id='IKDQd'></ul><sub id='IKDQd'></sub></form><legend id='IKDQd'></legend><bdo id='IKDQd'><pre id='IKDQd'><center id='IKDQd'></center></pre></bdo></b><th id='IKDQd'></th></span></q></dt></tr></i><div id='IKDQd'><tfoot id='IKDQd'></tfoot><dl id='IKDQd'><fieldset id='IKDQd'></fieldset></dl></div>

                • <bdo id='IKDQd'></bdo><ul id='IKDQd'></ul>
                  本文介绍了Neo4j - Graphaware reco4php - 命名空间问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试从 Neo4j 运行演示 - reco4php 页面位于 此链接我非常仔细地遵循了每个步骤,但最后却出现了一个奇怪的错误.

                  I'm trying to run the demo from Neo4j - reco4php page at This Link I followed every steps very carefully but i'm getting a strange error at the end.

                  让我更详细地解释一下:

                  let me explain in more details :

                  这是我要运行的代码:

                  require 'vendor/autoload.php';
                  
                  use GraphAwareCommonCypherStatement;
                  use GraphAwareCommonTypeNode;
                  use GraphAwareReco4PHPContextContext;
                  use GraphAwareReco4PHPEngineSingleDiscoveryEngine;
                  
                  class RatedByOthers extends SingleDiscoveryEngine
                  {
                  public function discoveryQuery(Node $input, Context $context)
                  {
                      $query = 'MATCH (input:User) WHERE id(input) = {id}
                      MATCH (input)-[:RATED]->(m)<-[:RATED]-(o)
                      WITH distinct o
                      MATCH (o)-[:RATED]->(reco)
                      RETURN distinct reco LIMIT 500';
                  
                      return Statement::create($query, ['id' => $input->identity()]);
                  }
                  
                  public function name()
                  {
                      return "rated_by_others";
                  }
                  }
                  

                  上面的代码扩展了类SingleDiscoveryEngine":

                  This above code extends the class "SingleDiscoveryEngine" :

                  declare (strict_types = 1);
                  
                  namespace GraphAwareReco4PHPEngine;
                  
                  use GraphAwareCommonResultRecord;
                  use GraphAwareCommonResultResultCollection;
                  use GraphAwareCommonTypeNode;
                  use GraphAwareReco4PHPContextContext;
                  use GraphAwareReco4PHPResultRecommendations;
                  use GraphAwareReco4PHPResultSingleScore;
                  
                  abstract class SingleDiscoveryEngine implements DiscoveryEngine
                  {
                  private static $DEFAULT_RECO_NAME = 'reco';
                  private static $DEFAULT_SCORE_NAME = 'score';
                  private static $DEFAULT_REASON_NAME = 'reason';
                  
                  
                  public function buildScore(Node $input, Node $item, Record $record, Context 
                  $context) : SingleScore
                  {
                      $score = $record->hasValue($this->scoreResultName()) ? $record- >value($this->scoreResultName()) : $this->defaultScore();
                      $reason = $record->hasValue($this->reasonResultName()) ? $record- >value($this->reasonResultName()) : null;
                  
                      return new SingleScore($score, $reason);
                  }
                  
                  
                  final public function produceRecommendations(Node $input, ResultCollection 
                  $resultCollection, Context $context) : Recommendations
                  {
                      $result = $resultCollection->get($this->name());
                      $recommendations = new Recommendations($context);
                  
                      foreach ($result->records() as $record) {
                          if ($record->hasValue($this->recoResultName())) {
                              $recommendations->add($record->get($this->recoResultName()), $this->name(), $this->buildScore($input, $record->get($this->recoResultName()), 
                  $record, $context));
                          }
                      }
                  
                      return $recommendations;
                  }
                  
                  /**
                   * {@inheritdoc}
                   */
                  public function recoResultName() : string
                  {
                      return self::$DEFAULT_RECO_NAME;
                  }
                  
                  /**
                   * {@inheritdoc}
                   */
                  public function scoreResultName() : string
                  {
                      return self::$DEFAULT_SCORE_NAME;
                  }
                  
                  /**
                   * {@inheritdoc}
                   */
                  public function reasonResultName() : string
                  {
                      return self::$DEFAULT_REASON_NAME;
                  }
                  
                  /**
                   * {@inheritdoc}
                   */
                  public function defaultScore() : float
                  {
                      return 1.0;
                  }
                  }
                  

                  上面的类还实现了下面的类:

                  and the above class is also implements the following class :

                  namespace GraphAwareReco4PHPEngine;
                  
                  use GraphAwareCommonCypherStatementInterface;
                  use GraphAwareCommonResultRecord;
                  use GraphAwareCommonTypeNode;
                  use GraphAwareCommonResultResultCollection;
                  use GraphAwareReco4PHPContextContext;
                  use GraphAwareReco4PHPResultRecommendations;
                  use GraphAwareReco4PHPResultSingleScore;
                  
                  interface DiscoveryEngine
                  {
                  /**
                   * @return string The name of the discovery engine
                   */
                  public function name() : string;
                  
                  /**
                   * The statement to be executed for finding items to be recommended.
                   *
                   * @param Node    $input
                   * @param Context $context
                   *
                   * @return GraphAwareCommonCypherStatement
                   */
                  public function discoveryQuery(Node $input, Context $context) : StatementInterface;
                  
                  /**
                   * Returns the score produced by the recommended item.
                   *
                   * @param Node    $input
                   * @param Node    $item
                   * @param Record  $record
                   * @param Context $context
                   *
                   * @return GraphAwareReco4PHPResultSingleScore A single score produced for the recommended item
                   */
                  public function buildScore(Node $input, Node $item, Record $record, Context $context) : SingleScore;
                  
                  /**
                   * Returns a collection of Recommendation object produced by this discovery engine.
                   *
                   * @param Node             $input
                   * @param ResultCollection $resultCollection
                   * @param Context          $context
                   *
                   * @return Recommendations
                   */
                  public function produceRecommendations(Node $input, ResultCollection $resultCollection, Context $context) : Recommendations;
                  
                  /**
                   * @return string The column identifier of the row result representing the recommended item (node)
                   */
                  public function recoResultName() : string;
                  
                  /**
                   * @return string The column identifier of the row result representing the score to be used, note that this
                   *                is not mandatory to have a score in the result. If empty, the score will be the float value returned by
                   *                <code>defaultScore()</code> or the score logic if the concrete class override the <code>buildScore</code>
                   *                method.
                   */
                  public function scoreResultName() : string;
                  
                  /**
                   * @return float The default score to be given to the discovered recommended item
                   */
                  public function defaultScore() : float;
                  }
                  

                  当我运行代码时出现以下错误:

                  And when I run the code I'm getting the following error :

                  致命错误:RatedByOthers::name() 的声明必须与 GraphAwareReco4PHPEngineDiscoveryEngine::name() 兼容:第 9 行/Applications/XAMPP/xamppfiles/htdocs/reco/index.php 中的字符串

                  Fatal error: Declaration of RatedByOthers::name() must be compatible with GraphAwareReco4PHPEngineDiscoveryEngine::name(): string in /Applications/XAMPP/xamppfiles/htdocs/reco/index.php on line 9

                  我检查了几个小时的代码,我认为它应该可以正常工作,但我不知道问题出在哪里.

                  I checked the code for hours and I think it should works fine and I have no idea where the problem comes from.

                  推荐答案

                  我自己找到了答案.

                  通过在函数启动后立即声明返回类型解决的问题:

                  The problem solved by declaring the type of return right after function starts :

                  public function discoveryQuery(Node $input, Context $context) : GraphAwareCommonCypherStatementInterface   {
                  $query = 'MATCH (input:User) WHERE id(input) = {id}
                  MATCH (input)-[:RATED]->(m)<-[:RATED]-(o)
                  WITH distinct o
                  MATCH (o)-[:RATED]->(reco)
                  RETURN distinct reco LIMIT 500';
                  
                  return Statement::create($query, ['id' => $input->identity()]);
                  }
                  
                  public function name() : string 
                  {
                  return "rated_by_others";
                  }
                  

                  希望它可以在未来帮助其他人.

                  hope it can help someone else in the future.

                  这篇关于Neo4j - Graphaware reco4php - 命名空间问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:setlocale(LC_ALL, 'en_GB.UTF8') 不适用于 Windows 下一篇:Cypher 查询作为 Neo4j 上的批处理操作

                  相关文章

                  最新文章

                • <small id='DIq0l'></small><noframes id='DIq0l'>

                  1. <legend id='DIq0l'><style id='DIq0l'><dir id='DIq0l'><q id='DIq0l'></q></dir></style></legend>

                    1. <i id='DIq0l'><tr id='DIq0l'><dt id='DIq0l'><q id='DIq0l'><span id='DIq0l'><b id='DIq0l'><form id='DIq0l'><ins id='DIq0l'></ins><ul id='DIq0l'></ul><sub id='DIq0l'></sub></form><legend id='DIq0l'></legend><bdo id='DIq0l'><pre id='DIq0l'><center id='DIq0l'></center></pre></bdo></b><th id='DIq0l'></th></span></q></dt></tr></i><div id='DIq0l'><tfoot id='DIq0l'></tfoot><dl id='DIq0l'><fieldset id='DIq0l'></fieldset></dl></div>
                        <bdo id='DIq0l'></bdo><ul id='DIq0l'></ul>

                      <tfoot id='DIq0l'></tfoot>