File tree 1 file changed +18
-3
lines changed 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change
1
+ '''
2
+ * Copyright (C) 2017 OwnThink Technologies Inc.
3
+ *
4
+ * Name : knowledgegraph.py - 知识图谱
5
+ * Author : Yener <yener@ownthink.com>
6
+ * Version : 0.01
7
+ * Description : 知识图谱api请求示范
8
+ '''
1
9
import requests
2
10
3
11
def mention2entity (mention ):
4
12
'''
5
- 提及->实体,根据提及获取歧义关系
13
+ * mention2entity - 提及->实体
14
+ * @mention: [in]提及
15
+ * 根据提及获取歧义关系
6
16
'''
7
17
url = 'https://api.ownthink.com/kg/ambiguous?mention={mention}' .format (mention = mention ) # 知识图谱API,歧义关系
8
18
sess = requests .get (url ) # 请求
@@ -12,7 +22,9 @@ def mention2entity(mention):
12
22
13
23
def entity2knowledge (entity ):
14
24
'''
15
- 实体->知识,根据实体获取实体知识
25
+ * entity2knowledge - 实体->知识
26
+ * @entity: [in]实体名
27
+ * 根据实体获取实体知识
16
28
'''
17
29
url = 'https://api.ownthink.com/kg/knowledge?entity={entity}' .format (entity = entity ) # 知识图谱API,实体知识
18
30
sess = requests .get (url ) # 请求
@@ -22,7 +34,10 @@ def entity2knowledge(entity):
22
34
23
35
def entity_attribute2value (entity , attribute ):
24
36
'''
25
- 实体&属性->属性值,根据实体、属性获取属性值
37
+ * entity_attribute2value - 实体&属性->属性值
38
+ * @entity: [in]实体名
39
+ * @attribute: [in]属性名
40
+ * 根据实体、属性获取属性值
26
41
'''
27
42
url = 'https://api.ownthink.com/kg/eav?entity={entity}&attribute={attribute}' .format (entity = entity , attribute = attribute ) # 知识图谱API,属性值
28
43
sess = requests .get (url ) # 请求
You can’t perform that action at this time.
0 commit comments