Indra Project

Code Examples


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 ="", 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()
  .addHeader("accept", "application/json")
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "<ADD HERE>")
  .addHeader("cache-control", "no-cache")

Response response = client.newCall(request).execute();



The indra service requires five parameters:


Specify the model language according to the two-letter-code [ISO 639-1] ( 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

Tech Details/Important TODOs (not relevant for users):