Goolgle knowledge graph API使用
来源:互联网 发布:izeeyu是什么软件 编辑:程序博客网 时间:2024/05/21 17:54
试了一下google的知识图谱API的使用,简单的整理了一下:
第一步:安装google的google-api-python-client包
pip install –upgrade google-api-python-client
第二步:创建API
在google的个人应用中心创建一个应用
https://console.developers.google.com/projectselector/apis/credentials?supportedpurview=project
在库中搜索Knowledge Graph Search API,并将该API授权给你创建的应用。
拷贝你应用的API key
第三步:调用google的API完成你需要的程序需求
将刚才的申请到的API key添加到你的应用中
import jsonimport urllibclass GooleKGAPI(object): def __init__(self): self.api_key = open('.api_key').read() def getResult(self,query,type): service_url = 'https://kgsearch.googleapis.com/v1/entities:search' params = { 'query': query, 'limit': 10, 'indent': True, 'key': self.api_key, } #https://kgsearch.googleapis.com/v1/entities:search?query=taylor+swift&key=API_KEY&limit=1&indent=True url = service_url + '?' + urllib.urlencode(params) #print url response = json.loads(urllib.urlopen(url).read()) print response for element in response['itemListElement']: print element['result']['name'] + ' (' + str(element['resultScore']) + ')'##testif __name__ == "__main__": gkg = GooleKGAPI() # example => bill gates gkg.getResult("Taylor Swift","Person")
阅读全文
0 0
- Goolgle knowledge graph API使用
- knowledge base, knowledge graph
- deep learning knowledge graph
- google knowledge graph
- Facebook Graph API使用介绍
- labeled graph---some basic knowledge
- Deep Learning 和 Knowledge Graph
- 知识图谱(knowledge graph)
- some win api knowledge
- 知识图谱(Knowledge Graph)小结
- Titan Graph DataBase 研究 (三)----Java API使用 上
- Titan Graph DataBase 研究 (三)----Java API使用 上
- == Deep Learning 和 Knowledge Graph ==
- how to become a data scientist - see knowledge graph
- Deep Learning 和 Knowledge Graph 引爆大数据革命
- Learning Entity and Relation Embeddings for Knowledge Graph Completion
- Introducing the Knowledge Graph: things, not strings【阅读翻译】
- 思维导图浅析入门知识图谱(Knowledge Graph)
- XFTP设置utf8编码的方法
- 在WIN7 搭建python 环境
- intellj idea 如何设置类头注释和方法注释
- web SSH项目报Table ‘performance_schema.session_variables’ doesn’t exist
- 在独立的java程序中使用jetty
- Goolgle knowledge graph API使用
- 2017.12.12 java多线程
- 开发项目遇到的大大小小问题总结
- 【深度学习】实时的物体识别-YOLO v2环境的搭建(4)
- MySQL 主从复制详解(详细)
- maven入门
- mysql中事件失效如何解决
- VOT2015 Benchmark简易教程
- PAT乙级1020. 月饼 (25) 背包问题