1 | <?php |
||
9 | class Client |
||
10 | { |
||
11 | /** |
||
12 | * API Key |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | private $api_key = ''; |
||
17 | |||
18 | /** |
||
19 | * Base URL |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | private $base_url = 'https://babelnet.io/v4/'; |
||
24 | |||
25 | /** |
||
26 | * @var array |
||
27 | */ |
||
28 | private $defaultParams = []; |
||
29 | |||
30 | /** |
||
31 | * Constructor |
||
32 | * |
||
33 | * @param string $api_key |
||
34 | * @param array $defaultParams |
||
35 | */ |
||
36 | public function __construct($api_key, array $defaultParams = []) |
||
41 | |||
42 | /** |
||
43 | * Executes an api call |
||
44 | * @param string $service |
||
45 | * @param array $params |
||
46 | * @throws \Exception |
||
47 | * @return mixed |
||
48 | */ |
||
49 | private function exec($service, $params = array()) |
||
70 | |||
71 | /** |
||
72 | * Returns a param list from a method-reflection and his params |
||
73 | * |
||
74 | * @param string $method |
||
75 | * @param array $args |
||
76 | * @return array |
||
77 | */ |
||
78 | private function getParamsByArguments($method, $args) |
||
99 | |||
100 | /** |
||
101 | * @see http://babelnet.org/guide#RetrieveBabelNetversion |
||
102 | * @throws \Exception |
||
103 | * @return string |
||
104 | */ |
||
105 | public function getVersion() |
||
110 | |||
111 | /** |
||
112 | * @see http://babelnet.org/guide#RetrievetheIDsoftheBabelsynsets(concepts)denotedbyagivenword |
||
113 | * @param string $word |
||
114 | * @param string $lang |
||
115 | * @param string $filterLangs |
||
116 | * @param string $pos |
||
117 | * @param string $source |
||
118 | * @param string $normalizer |
||
119 | * @throws \Exception |
||
120 | * @return string[] |
||
121 | */ |
||
122 | public function getSynsetIds($word, $lang = null, $filterLangs = null, $pos = null, $source = null, $normalizer = null) |
||
126 | |||
127 | /** |
||
128 | * @see http://babelnet.org/guide#Retrievetheinformationofagivensynset |
||
129 | * @param string $id |
||
130 | * @param string $filterLangs |
||
131 | * @throws \Exception |
||
132 | * @return array |
||
133 | */ |
||
134 | public function getSynsetById($id, $filterLangs = null) |
||
138 | |||
139 | /** |
||
140 | * @see http://babelnet.org/guide#RetrievetheIDsoftheBabelsynsets(concepts)denotedbyagivenword |
||
141 | * @param string $word |
||
142 | * @param string $lang |
||
143 | * @param string $filterLangs |
||
144 | * @param string $pos |
||
145 | * @param string $source |
||
146 | * @param string $normalizer |
||
147 | * @throws \Exception |
||
148 | * @return array |
||
149 | */ |
||
150 | public function getSynsets($word, $lang = null, $filterLangs = null, $pos = null, $source = null, $normalizer = null) |
||
158 | |||
159 | /** |
||
160 | * @see http://babelnet.org/guide#Retrievethesensesofagivenword |
||
161 | * @param string $word |
||
162 | * @param string $lang |
||
163 | * @param string $filterLangs |
||
164 | * @param string $pos |
||
165 | * @param string $source |
||
166 | * @param string $normalizer |
||
167 | * @throws \Exception |
||
168 | * @return array |
||
169 | */ |
||
170 | public function getSenses($word, $lang = null, $filterLangs = null, $pos = null, $source = null, $normalizer = null) |
||
174 | |||
175 | /** |
||
176 | * @see http://babelnet.org/guide#RetrieveedgesofagivenBabelNetsynset6 |
||
177 | * @param string $id |
||
178 | * @throws \Exception |
||
179 | * @return array |
||
180 | */ |
||
181 | public function getEdges($id) |
||
185 | } |
||
186 |