requests
.```python
import requests import json
pairs = [ {'t1': 'house', 't2': 'beer'}, {'t1': 'car', 't2': 'engine'}]
data = {'corpus': 'wiki-2014', 'model': 'W2V', 'language': 'EN', 'scoreFunction': 'COSINE', 'pairs': pairs}
headers = { 'accept': "application/json", 'content-type': "application/json", 'cache-control': "no-cache" }
res = requests.post("http://alphard.fim.uni-passau.de:8916/indra/v1/relatedness", data=json.dumps(data), headers=headers) res.raiseforstatus() print(res.json()) ```
xml
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.4.1</version>
</dependency>
```java OkHttpClient client = new OkHttpClient(); String content = "{\"corpus\": \"wiki-2014\", \"model\": \"W2V\", \"language\": \"EN\"," + "\"scoreFunction\": \"COSINE\", \"pairs\": [{\"t1\": \"wife\", \"t2\": \"mother\"}]}";
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, content);
Request request = new Request.Builder()
.url("http://indra.amtera.net:80/indra/v1/relatedness")
.post(body)
.addHeader("accept", "application/json")
.addHeader("content-type", "application/json")
.addHeader("authorization", "<ADD HERE>")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
```
The indra service requires five parameters:
Specify the model language according to the two-letter-code [ISO 639-1] (https://en.wikipedia.org/wiki/ListofISO639-1codes). The following languages are available in the current version of Indra:
Define the corpus from which the model where generated. Currently there is only one option of model per language. for Korean, the corpus name is wiki-2016, while for all others it is wiki-2014.
Specify the distributional semantics model. Four models are available:
Specify the function applied to calculate the relatedness between vectors
This Project generates two main artifacts:
If you got the source files just run mvn package
to build all aritifacts.
There are a lot of TODOs scattered all over the code but here the most important ones: