定制 freearhey/knowledge-graph 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

freearhey/knowledge-graph

Composer 安装命令:

composer require freearhey/knowledge-graph

包简介

A simple PHP client for working with Google Knowledge Graph API

README 文档

README

A simple PHP client for working with Google Knowledge Graph API.

Installation

composer require freearhey/knowledge-graph

Usage

require_once('vendor/autoload.php');

use KnowledgeGraph\Client;
use KnowledgeGraph\KnowledgeGraph;

$client = new Client();

$client->setKey('YOUR_API_KEY'); // More about API Key here: https://developers.google.com/knowledge-graph/how-tos/authorizing

$graph = new KnowledgeGraph($client);

Available Methods

search()

The search method give you a way to search in Knowledge Graph by entity name.

$results = $graph->search($query, $type, $lang, $limit);

Arguments:

  • $query: term to search (required)
  • $type: specify the type of results (e.g. "Book") (List of available types: https://developers.google.com/knowledge-graph/)
  • $lang: specify the results language
  • $limit: set a custom limit (default: 20)

Example:

$results = $graph->search('taylor swift');

/*
  Collection {
    #items: array:20 [
      0 => SearchResult {
        id: "/m/0dl567"
        score: 1466.352905
        name: "Taylor Swift"
        type: array:2 [
          0 => "Thing"
          1 => "Person"
        ]
        description: "American singer"
        image: array:2 [
          "contentUrl" => "http://t0.gstatic.com/images?q=tbn:ANd9GcST848UJ0u31E6aoQfb2nnKZFyad7rwNF0ZLOCACGpu4jnboEzV"
          "url" => "https://en.wikipedia.org/wiki/Begin_Again_(Taylor_Swift_song)"
        ]
        detailedDescription: array:3 [
          "articleBody" => "Taylor Alison Swift is an American singer-songwriter. As one of the world's leading contemporary recording artists, she is known for narrative songs about her p ▶"
          "url" => "https://en.wikipedia.org/wiki/Taylor_Swift"
          "license" => "https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"
        ]
        url: "http://taylorswift.com/"
      }
      ...
    ]
  }
 */

The search method always returns Illuminate\Support\Collection class with results. This means you can use all the methods available in Laravel's Collections.

find()

The find method give you a way to search by entity ID.

$results = $graph->find($id, $lang);

Arguments:

  • $id: ID to search (e.g. "/m/0dl567")
  • $lang: specify the results language

Example:

$results = $graph->find('/m/02j81');

/*
  SearchResult { 
    id: "/m/02j81"
    score: 26.98455
    name: "Eiffel Tower"
    type: array:5 [
      0 => "Thing"
      1 => "CivicStructure"
      2 => "Place"
      3 => "TouristAttraction"
      4 => "Organization"
    ]
    description: "Tower in Paris, France"
    image: array:2 [
      "contentUrl" => "http://t1.gstatic.com/images?q=tbn:ANd9GcSao5YmaJqJVcSi60m9ypkaIC6bjKVJdoocuGBzgyTIu4MaMJ-t"
      "url" => "https://commons.wikimedia.org/wiki/File:Eiffel_tower.svg"
    ]
    detailedDescription: array:3 [
      "articleBody" => "The Eiffel Tower is a wrought-iron lattice tower on the Champ de Mars in Paris, France. It is named after the engineer Gustave Eiffel, whose company designed an ▶"
      "url" => "https://en.wikipedia.org/wiki/Eiffel_Tower"
      "license" => "https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"
    ]
    url: "http://www.eiffel-tower.com/"
  }
 */

Testing

API_KEY=YOUR_API_KEY vendor/bin/phpunit

Contribution

If you find a bug or want to contribute to the code or documentation, you can help by submitting an issue or a pull request.

License

Knowledge Graph is licensed under the MIT license.

freearhey/knowledge-graph 适用场景与选型建议

freearhey/knowledge-graph 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 40.52k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2017 年 10 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「api」 「client」 「google」 「graph」 「knowledge」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 freearhey/knowledge-graph 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 freearhey/knowledge-graph 我们能提供哪些服务?
定制开发 / 二次开发

基于 freearhey/knowledge-graph 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 40.52k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-10-19