How to query BabelNet programmatically

HTTP API

This page describes how you can query BabelNet through an HTTP interface that returns JSON. You can append the key parameter to the HTTP requests as shown in the examples below. To obtain an API key please read the key & limits page. All requests must be executed using the GET method and they should include the Accept-Encoding: gzip header in order to obtain compressed content.

NOTE: Since the BabelNet 3.5 release, any data retrieved with the API is by default only in the search language. Should one want to retrieve other languages, it is possible to append the specific parameter filterLangs present in the most important calls. It is not possible to retrieve more than three languages other than the search language.

The current version 4 of the HTTP API is fully compatible with previous version 3.

LICENSES: All the data of the external resources are released under the terms of the respective owners' licenses.

Retrieve BabelNet version

Parameters

Name Type Description
key string Required. API key obtained after signing up to BabelNet (see key & limits)

Response example

{
  "version": "V3_7"
}

Retrieve the IDs of the Babel synsets (concepts) denoted by a given word

Parameters

Name Type Description
word string Required. The word you want to search for
langs Language Required. The language of the word. Accepts multiple values. Example: https://babelnet.io/v4/getSynsetIds?word=apple&langs=EN&langs=IT&pos=NOUN&key=<your_key>
filterLangs Language The languages in which the data are to be retrieved. Default value is the search language and accepts not more than 3 languages except the search language. Example: https://babelnet.io/v4/getSynsetIds?word=apple&langs=EN&langs=IT&filterLangs=DE&filterLangs=IT&pos=NOUN&key=<your_key>
pos POS Returns only the synsets containing this part of speech (NOUN, VERB, etc). Accepts only a single value. Example: https://babelnet.io/v4/getSynsetIds?word=apple&lang=EN&pos=NOUN&key=<your_key>
source Source Returns only the synsets containing these sources (WIKT, WIKIDATA, etc). Accepts multiple values. Example: https://babelnet.io/v4/getSynsetIds?word=apple&lang=EN&source=WIKT&source=WIKIDATA&key=<your_key>
normalizer boolean Enables normalized search
key string Required. API key obtained after signing up to BabelNet (see key & limits)

Response example

[
  {
    "id": "bn:00615676n"
  },
  {
    "id": "bn:03740610n"
  },
  {
    "id": "bn:00005076n"
  },
  {
    "id": "bn:01783257n"
  },
  {
    "id": "bn:14289548n"
  },
  {
    "id": "bn:00289737n"
  },
  {
    "id": "bn:03739345n"
  },
  {
    "id": "bn:03283215n"
  },
  {
    "id": "bn:09816241n"
  },
  {
    "id": "bn:00319426n"
  },
  {
    "id": "bn:14792761n"
  },
  {
    "id": "bn:00005055n"
  },
  {
    "id": "bn:03174949n"
  },
  {
    "id": "bn:00005054n"
  },
  {
    "id": "bn:00955003n"
  }
]

Code samples

import urllib2
import urllib
import json
import gzip

from StringIO import StringIO

service_url = 'https://babelnet.io/v4/getSynsetIds'

word = 'apple'
lang = 'EN'
key  = 'KEY'

params = {
        'word' : word,
        'langs' : lang,
        'key'  : key
}

url = service_url + '?' + urllib.urlencode(params)
request = urllib2.Request(url)
request.add_header('Accept-encoding', 'gzip')
response = urllib2.urlopen(request)

if response.info().get('Content-Encoding') == 'gzip':
        buf = StringIO( response.read())
        f = gzip.GzipFile(fileobj=buf)
        data = json.loads(f.read())
        for result in data:
                print result['id']
require "net/http"
require 'json'

uri = URI("https://babelnet.io/v4/getSynsetIds?")

params = {
  :word => 'apple',
  :langs => 'EN',
  :key  => 'KEY'
}

uri.query = URI.encode_www_form(params)

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

response = http.request(Net::HTTP::Get.new(uri.request_uri))

if response.is_a?(Net::HTTPSuccess)
  json = JSON.parse(response.body)
  json.each do |entry|
    puts entry['id']
  end
end
<!DOCTYPE html>
<html>
<head>
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"><script>
</head>
<body>
<script>
    var service_url = 'https://babelnet.io/v4/getSynsetIds';
    var word = 'apple'
    var lang = 'EN'
    var key  = 'KEY'

    var params = {
        'word': word,
	'langs': lang,
	'key' : key
    };

    $.getJSON(service_url + "?", params, function(response) {
        $.each(response, function(key, val) {
            $('<div>', {text:val['id']}).appendTo(document.body);
        });
    });
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php

  $service_url = 'https://babelnet.io/v4/getSynsetIds';

  $word = 'apple';
  $lang = 'EN';
  $key  = 'KEY';

  $params = array(
    'word' => $word,
    'langs'  => $lang,
    'key'   => $key
  );

  $url = $service_url . '?' . http_build_query($params);

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
  $response = json_decode(curl_exec($ch), true);
  curl_close($ch);

  foreach($response as $result) {
    echo $result['id'] . '<br/>';
  }
?>
</body>
</html>

Retrieve the information of a given synset

Parameters

Name Type Description
id string Required. id of the synset you want to retrieve (can also be a WordNet id "wn:")
key string Required. API key obtained after signing up to BabelNet (see key & limits)
filterLangs Language The languages in which the data are to be retrieved. Default value is the English and accepts not more than 3 languages except the default language. Example: https://babelnet.io/v4/getSynset?id=bn:14792761n&filterLangs=IT&key=<your_key>

Response example

{
  "senses": [
    {
      "lemma": "Apple_System_on_Chips",
      "simpleLemma": "Apple_System_on_Chips",
      "source": "WIKIRED",
      "sensekey": "",
      "sensenumber": 0,
      "frequency": 0,
      "position": 1,
      "language": "EN",
      "pos": "NOUN",
      "synsetID": {
        "id": "bn:14792761n",
        "pos": "NOUN",
        "source": "BABELNET"
      },
      "translationInfo": "",
      "pronunciations": {
        "audios": [],
        "transcriptions": []
      }
    },
    {
      "lemma": "Apple_System_on_a_Chip",
      "simpleLemma": "Apple_System_on_a_Chip",
      "source": "WIKIRED",
      "sensekey": "",
      "sensenumber": 0,
      "frequency": 0,
      "position": 1,
      "language": "EN",
      "pos": "NOUN",
      "synsetID": {
        "id": "bn:14792761n",
        "pos": "NOUN",
        "source": "BABELNET"
      },
      "translationInfo": "",
      "pronunciations": {
        "audios": [],
        "transcriptions": []
      }
    },
    {
      "lemma": "Apple_Ax",
      "simpleLemma": "Apple_Ax",
      "source": "WIKIRED",
      "sensekey": "",
      "sensenumber": 0,
      "frequency": 0,
      "position": 1,
      "language": "EN",
      "pos": "NOUN",
      "synsetID": {
        "id": "bn:14792761n",
        "pos": "NOUN",
        "source": "BABELNET"
      },
      "translationInfo": "",
      "pronunciations": {
        "audios": [],
        "transcriptions": []
      }
    },
    {
      "lemma": "Apple_system_on_a_chip",
      "simpleLemma": "Apple_system_on_a_chip",
      "source": "WIKI",
      "sensekey": "",
      "sensenumber": 0,
      "frequency": 0,
      "position": 1,
      "language": "EN",
      "pos": "NOUN",
      "synsetID": {
        "id": "bn:14792761n",
        "pos": "NOUN",
        "source": "BABELNET"
      },
      "translationInfo": "",
      "pronunciations": {
        "audios": [],
        "transcriptions": []
      },
      "freebaseId": "0gysszs"
    },
    {
      "lemma": "Apple_(system_on_chip)",
      "simpleLemma": "Apple",
      "source": "WIKIRED",
      "sensekey": "",
      "sensenumber": 0,
      "frequency": 0,
      "position": 1,
      "language": "EN",
      "pos": "NOUN",
      "synsetID": {
        "id": "bn:14792761n",
        "pos": "NOUN",
        "source": "BABELNET"
      },
      "translationInfo": "",
      "pronunciations": {
        "audios": [],
        "transcriptions": [
          "[/ˈæpəl/]"
        ]
      }
    },
    {
      "lemma": "Apple_a",
      "simpleLemma": "Apple_a",
      "source": "WIKIRED",
      "sensekey": "",
      "sensenumber": 0,
      "frequency": 0,
      "position": 1,
      "language": "EN",
      "pos": "NOUN",
      "synsetID": {
        "id": "bn:14792761n",
        "pos": "NOUN",
        "source": "BABELNET"
      },
      "translationInfo": "",
      "pronunciations": {
        "audios": [],
        "transcriptions": []
      }
    },
    {
      "lemma": "Apple_system_on_chips",
      "simpleLemma": "Apple_system_on_chips",
      "source": "WIKIRED",
      "sensekey": "",
      "sensenumber": 0,
      "frequency": 0,
      "position": 1,
      "language": "EN",
      "pos": "NOUN",
      "synsetID": {
        "id": "bn:14792761n",
        "pos": "NOUN",
        "source": "BABELNET"
      },
      "translationInfo": "",
      "pronunciations": {
        "audios": [],
        "transcriptions": []
      }
    },
    {
      "lemma": "Apple_Ax_(System_on_Chip)",
      "simpleLemma": "Apple_Ax",
      "source": "WIKIRED",
      "sensekey": "",
      "sensenumber": 0,
      "frequency": 0,
      "position": 1,
      "language": "EN",
      "pos": "NOUN",
      "synsetID": {
        "id": "bn:14792761n",
        "pos": "NOUN",
        "source": "BABELNET"
      },
      "translationInfo": "",
      "pronunciations": {
        "audios": [],
        "transcriptions": []
      }
    },
    {
      "lemma": "Apple_System_on_Chips",
      "simpleLemma": "Apple_System_on_Chips",
      "source": "WIKIDATA",
      "sensekey": "Q406283#1",
      "sensenumber": 0,
      "frequency": 0,
      "position": 1,
      "language": "EN",
      "pos": "NOUN",
      "synsetID": {
        "id": "bn:14792761n",
        "pos": "NOUN",
        "source": "BABELNET"
      },
      "translationInfo": "",
      "pronunciations": {
        "audios": [],
        "transcriptions": []
      }
    }
  ],
  "synsetSource": "WIKI",
  "wnOffsets": [],
  "mainSense": "Apple_system_on_a_chip",
  "glosses": [
    {
      "source": "WIKI",
      "sourceSense": "Apple_system_on_a_chip",
      "language": "EN",
      "gloss": "Apple Inc. has developed a range of \"Systems on Chip\" to power their mobile consumer devices.",
      "tokens": []
    }
  ],
  "examples": [],
  "images": [],
  "synsetType": "CONCEPT",
  "categories": [
    {
      "category": "2011_introductions",
      "language": "EN"
    },
    {
      "category": "Apple_Inc._hardware",
      "language": "EN"
    },
    {
      "category": "ARM_architecture",
      "language": "EN"
    },
    {
      "category": "Microprocessors",
      "language": "EN"
    },
    {
      "category": "Microprocessore",
      "language": "IT"
    },
    {
      "category": "System_on_a_chip",
      "language": "EN"
    }
  ],
  "translations": {},
  "domains": {
    "CULTURE_AND_SOCIETY": 0.389990717177
  },
  "lnToCompound": {}
}

Code samples

import urllib2
import urllib
import json
import gzip

from StringIO import StringIO

service_url = 'https://babelnet.io/v4/getSynset'

id = 'bn:14792761n'
key  = 'KEY'

params = {
	'id' : id,
	'key'  : key
}

url = service_url + '?' + urllib.urlencode(params)
request = urllib2.Request(url)
request.add_header('Accept-encoding', 'gzip')
response = urllib2.urlopen(request)

if response.info().get('Content-Encoding') == 'gzip':
	buf = StringIO( response.read())
	f = gzip.GzipFile(fileobj=buf)
	data = json.loads(f.read())

	# retrieving BabelSense data
	senses = data['senses']
	for result in senses:
		lemma = result.get('lemma')
		language = result.get('language')
		print language.encode('utf-8') + "\t" + str(lemma.encode('utf-8'))

	print '\n'
	# retrieving BabelGloss data
	glosses = data['glosses']
	for result in glosses:
		gloss = result.get('gloss')
		language = result.get('language')
		print language.encode('utf-8') + "\t" + str(gloss.encode('utf-8'))

	print '\n'
	# retrieving BabelImage data
	images = data['images']
	for result in images:
		url = result.get('url')
		language = result.get('language')
		name = result.get('name')
		print language.encode('utf-8') +"\t"+ str(name.encode('utf-8')) +"\t"+ str(url.encode('utf-8'))
require "net/http"
require 'json'

uri = URI("https://babelnet.io/v4/getSynset?")

params = {
  :id => 'bn:14792761n',
  :key  => 'KEY'
}

uri.query = URI.encode_www_form(params)

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

response = http.request(Net::HTTP::Get.new(uri.request_uri))

if response.is_a?(Net::HTTPSuccess)
  json = JSON.parse(response.body)

  # retrieving BabelSense data
  json['senses'].each do |entry|
    lemma = entry['lemma']
    language = entry['language']
    puts language + "\t" + lemma
  end

  puts "\n"
  # retrieving BabelGloss data
  json['glosses'].each do |entry|
    gloss = entry['gloss']
    language = entry['language']
    puts language + "\t" + gloss
  end

  puts "\n"
  # retrieving BabelImage data
  json['images'].each do |entry|
    url = entry['url']
    language = entry['language']
    name = entry['name']
    puts language + "\t" + name + "\t" + url
  end
end
<!DOCTYPE html>
<html>
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
</head>
<body>
<script>
    var service_url = 'https://babelnet.io/v4/getSynset';
    var id = 'bn:14792761n'
    var key = 'KEY'

    var params = {
        'id'  : id,
        'key' : key
    };

    $.getJSON(service_url + "?", params, function(response) {

        $.each(response['senses'], function(key, val) {
            var entry = "Language: " + val['language']
                + "<br/>Lemma: " + val['lemma'] + "<br/><br/>";

            $('<div>', {html:entry}).appendTo(document.body);
        });

        $.each(response['glosses'], function(key, val) {
            var entry = "Language: " + val['language']
                + "<br/>Gloss: " + val['gloss'] + "<br/><br/>";

            $('<div>', {html:entry}).appendTo(document.body);
        });

        $.each(response['images'], function(key, val) {
            var entry = "Language: " + val['language'] + "<br/>Name: "
                + val['name'] + "<br/>Url: " + val['url'] + "<br/><br/>";

            $('<div>', {html:entry}).appendTo(document.body);
        });

    });
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php

  $service_url = 'https://babelnet.io/v4/getSynset';

  $id = 'bn:14792761n';
  $key  = 'KEY';

  $params = array(
    'id'    => $id,
    'key'   => $key
  );

  $url = $service_url . '?' . http_build_query($params);

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
  $response = json_decode(curl_exec($ch), true);
  curl_close($ch);

  # retrieving BabelSense data
  foreach($response['senses'] as $result) {
    $lemma = $result['lemma'];
    $language = $result['language'];
    echo "Language: " . $language
        . "<br/>Lemma: " . $lemma . "<br/><br/>";
  }

  # retrieving BabelGloss data
  foreach($response['glosses'] as $result) {
    $gloss = $result['gloss'];
    $language = $result['language'];
    echo "Language: " . $language
        . "<br/>Gloss: " . $gloss . "<br/><br/>";
  }

  # retrieving BabelImage data
  foreach($response['images'] as $result) {
    $url = $result['url'];
    $language = $result['language'];
    $name = $result['name'];
    echo "Language: " . $language
        . "<br/>Name: " . $name
        . "<br/>Url: " . $url . "<br/><br/>";
  }

?>
</body>
</html>

Retrieve the senses of a given word

Parameters

Name Type Description
word string Required. The word you want to search for
lang Language Required. The language of the word
filterLangs Language The languages in which the data are to be retrieved. Default value is the search language and accepts not more than 3 languages except the search language. Example: https://babelnet.io/v4/getSenses?word=BabelNet&lang=EN&pos=VERB&filterLangs=IT&key=<your_key>
pos POS Returns only the synsets containing this part of speech (NOUN, VERB, etc). Accepts only a single value. Example: https://babelnet.io/v4/getSenses?word=BabelNet&lang=EN&pos=VERB&key=<your_key>
source Source Returns only the synsets containing these sources (WIKT, WIKIDATA, etc). Accepts multiple values. Example: https://babelnet.io/v4/getSenses?word=BabelNet&lang=EN&source=WIKT&source=WIKIDATA&key=<your_key>
normalizer boolean Enables normalized search
key string Required. API key obtained after signing up to BabelNet (see key & limits)

Response example

[
  {
    "lemma": "BabelNet",
    "simpleLemma": "BabelNet",
    "source": "WIKI",
    "sensekey": "",
    "sensenumber": 0,
    "frequency": 0,
    "position": 1,
    "language": "EN",
    "pos": "NOUN",
    "synsetID": {
      "id": "bn:03083790n",
      "pos": "NOUN",
      "source": "BABELNET"
    },
    "translationInfo": "",
    "pronunciations": {
      "audios": [],
      "transcriptions": []
    },
    "freebaseId": "0n5v3cj"
  },
  {
    "lemma": "BabelNet",
    "simpleLemma": "BabelNet",
    "source": "WIKI",
    "sensekey": "",
    "sensenumber": 0,
    "frequency": 0,
    "position": 1,
    "language": "IT",
    "pos": "NOUN",
    "synsetID": {
      "id": "bn:03083790n",
      "pos": "NOUN",
      "source": "BABELNET"
    },
    "translationInfo": "",
    "pronunciations": {
      "audios": [],
      "transcriptions": []
    }
  },
  {
    "lemma": "Babelnet",
    "simpleLemma": "Babelnet",
    "source": "WIKIRED",
    "sensekey": "",
    "sensenumber": 0,
    "frequency": 0,
    "position": 1,
    "language": "EN",
    "pos": "NOUN",
    "synsetID": {
      "id": "bn:03083790n",
      "pos": "NOUN",
      "source": "BABELNET"
    },
    "translationInfo": "",
    "pronunciations": {
      "audios": [],
      "transcriptions": []
    }
  },
  {
    "lemma": "BabelNet",
    "simpleLemma": "BabelNet",
    "source": "WIKIDATA",
    "sensekey": "Q4837690#1",
    "sensenumber": 0,
    "frequency": 0,
    "position": 1,
    "language": "EN",
    "pos": "NOUN",
    "synsetID": {
      "id": "bn:03083790n",
      "pos": "NOUN",
      "source": "BABELNET"
    },
    "translationInfo": "",
    "pronunciations": {
      "audios": [],
      "transcriptions": []
    },
    "freebaseId": "0n5v3cj"
  },
  {
    "lemma": "BabelNet",
    "simpleLemma": "BabelNet",
    "source": "WIKIDATA",
    "sensekey": "Q4837690#1",
    "sensenumber": 0,
    "frequency": 0,
    "position": 1,
    "language": "IT",
    "pos": "NOUN",
    "synsetID": {
      "id": "bn:03083790n",
      "pos": "NOUN",
      "source": "BABELNET"
    },
    "translationInfo": "",
    "pronunciations": {
      "audios": [],
      "transcriptions": []
    }
  },
  {
    "lemma": "BabelNet",
    "simpleLemma": "BabelNet",
    "source": "OMWIKI",
    "sensekey": "1499705#1",
    "sensenumber": 0,
    "frequency": 0,
    "position": 1,
    "language": "IT",
    "pos": "NOUN",
    "synsetID": {
      "id": "bn:03083790n",
      "pos": "NOUN",
      "source": "BABELNET"
    },
    "translationInfo": "",
    "pronunciations": {
      "audios": [],
      "transcriptions": []
    }
  },
  {
    "lemma": "BabelNet",
    "simpleLemma": "BabelNet",
    "source": "OMWIKI",
    "sensekey": "1499705#1",
    "sensenumber": 0,
    "frequency": 0,
    "position": 1,
    "language": "EN",
    "pos": "NOUN",
    "synsetID": {
      "id": "bn:03083790n",
      "pos": "NOUN",
      "source": "BABELNET"
    },
    "translationInfo": "",
    "pronunciations": {
      "audios": [],
      "transcriptions": []
    },
    "freebaseId": "0n5v3cj"
  },
  {
    "lemma": "BabelNet",
    "simpleLemma": "BabelNet",
    "source": "WIKI",
    "sensekey": "",
    "sensenumber": 0,
    "frequency": 0,
    "position": 1,
    "language": "EN",
    "pos": "NOUN",
    "synsetID": {
      "id": "bn:03083790n",
      "pos": "NOUN",
      "source": "BABELNET"
    },
    "translationInfo": "",
    "pronunciations": {
      "audios": [],
      "transcriptions": []
    },
    "freebaseId": "0n5v3cj"
  },
  {
    "lemma": "Babelnet",
    "simpleLemma": "Babelnet",
    "source": "WIKIRED",
    "sensekey": "",
    "sensenumber": 0,
    "frequency": 0,
    "position": 1,
    "language": "EN",
    "pos": "NOUN",
    "synsetID": {
      "id": "bn:03083790n",
      "pos": "NOUN",
      "source": "BABELNET"
    },
    "translationInfo": "",
    "pronunciations": {
      "audios": [],
      "transcriptions": []
    }
  },
  {
    "lemma": "BabelNet",
    "simpleLemma": "BabelNet",
    "source": "WIKIDATA",
    "sensekey": "Q4837690#1",
    "sensenumber": 0,
    "frequency": 0,
    "position": 1,
    "language": "EN",
    "pos": "NOUN",
    "synsetID": {
      "id": "bn:03083790n",
      "pos": "NOUN",
      "source": "BABELNET"
    },
    "translationInfo": "",
    "pronunciations": {
      "audios": [],
      "transcriptions": []
    },
    "freebaseId": "0n5v3cj"
  },
  {
    "lemma": "BabelNet",
    "simpleLemma": "BabelNet",
    "source": "OMWIKI",
    "sensekey": "1499705#1",
    "sensenumber": 0,
    "frequency": 0,
    "position": 1,
    "language": "EN",
    "pos": "NOUN",
    "synsetID": {
      "id": "bn:03083790n",
      "pos": "NOUN",
      "source": "BABELNET"
    },
    "translationInfo": "",
    "pronunciations": {
      "audios": [],
      "transcriptions": []
    },
    "freebaseId": "0n5v3cj"
  }
]

Code samples

import urllib2
import urllib
import json
import gzip

from StringIO import StringIO

service_url = 'https://babelnet.io/v4/getSenses'

word = 'BabelNet'
lang = 'EN'
key  = 'KEY'

params = {
	'word' : word,
	'lang' : lang,
	'key'  : key
}

url = service_url + '?' + urllib.urlencode(params)
request = urllib2.Request(url)
request.add_header('Accept-encoding', 'gzip')
response = urllib2.urlopen(request)

if response.info().get('Content-Encoding') == 'gzip':
	buf = StringIO( response.read())
	f = gzip.GzipFile(fileobj=buf)
	data = json.loads(f.read())

	# retrieving BabelSense data
	for result in data:
		lemma = result.get('lemma')
		language = result.get('language')
		source = result.get('source')
		print language.encode('utf-8') \
			+"\t"+ str(lemma.encode('utf-8')) \
			+"\t"+ str(source.encode('utf-8'))
require "net/http"
require 'json'

uri = URI("https://babelnet.io/v4/getSenses?")

params = {
  :word => 'BabelNet',
  :lang => 'EN',
  :key  => 'KEY'
}

uri.query = URI.encode_www_form(params)

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

response = http.request(Net::HTTP::Get.new(uri.request_uri))

if response.is_a?(Net::HTTPSuccess)
  json = JSON.parse(response.body)
  json.each do |entry|
    lemma = entry['lemma']
    language = entry['language']
    source = entry['source']
    puts language +"\t"+ lemma +"\t"+ source
  end
end
<!DOCTYPE html>
<html>
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
</head>
<body>
<script>
    var service_url = 'https://babelnet.io/v4/getSenses';
    var word = 'BabelNet'
    var lang = 'EN'
    var key  = 'KEY'

    var params = {
        'word': word,
        'lang': lang,
        'key' : key
    };

    $.getJSON(service_url + "?", params, function(response) {
        $.each(response, function(key, val) {
            var entry = "Language: " + val['language']
                + "<br/>Lemma: " + val['lemma']
                + "<br/>Source: " + val['source'] + "<br/><br/>";
            $('<div>', {html:entry}).appendTo(document.body);
        });
    });
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php

  $service_url = 'http://babelnet.io/v4/getSenses';

  $word = 'BabelNet';
  $lang = 'EN';
  $key  = 'KEY';

  $params = array(
    'word'  => $word,
    'lang'  => $lang,
    'key'   => $key
  );

  $url = $service_url . '?' . http_build_query($params);

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
  $response = json_decode(curl_exec($ch), true);
  curl_close($ch);

  foreach($response as $result) {
    $lemma = $result['lemma'];
    $language = $result['language'];
    $source = $result['source'];
    echo "Language: " . $language
        . "<br/>Lemma: " . $lemma
        . "<br/>Source: " . $source . "<br/><br/>";
  }
?>
</body>
</html>

Retrieve a list of BabelNet IDs given a resource identifier

Parameters

  • First type of call with parameters id, language and pos. Necessary for the resources: Wikipedia and Wikiquote.

    Name Type Description
    id string Required. The page title you want to search for
    lang Language The language of the word
    filterLangs Language The languages in which the data are to be retrieved. Default value is the search language and accepts not more than 3 languages except the search language. Example: https://babelnet.io/v4/getSynsetIdsFromResourceID?id=BabelNet&lang=EN&pos=NOUN&source=WIKI&filterLangs=IT&key=<your_key>
    pos POS Returns only the synsets containing this part of speech (NOUN, VERB, etc). Accepts only a single value.
    source Source Required. The resource of the page title specified. Accepts only the values WIKI or WIKIQU.
    key string Required. API key obtained after signing up to BabelNet (see key & limits)
  • Second type of call with parameter id. Necessary for the remaining resources.

    Name Type Description
    id string Required. id of the synset you want to retrieve (bn:03083790n, Q4837690, etc.)
    filterLangs Language The languages in which the data are to be retrieved. Default value is the English and accepts not more than 3 languages except the default language. Example: https://babelnet.io/v4/getSynsetIdsFromResourceID?id=Q4837690&source=WIKIDATA&filterLangs=ITkey=<your_key>
    source Source Required. The resource of the identifier specified. Accepts all the resource values except WIKI and WIKIQU.
    wnVersion string If the value of the parameter source is WN (WordNet), using this field allow to specify the WordNet version of the parameter id. Example:
    https://babelnet.io/v4/getSynsetIdsFromResourceID?id=wn:02398357v&wnVersion=WN_21&source=WN&key=<your_key>
    key string Required. API key obtained after signing up to BabelNet (see key & limits)

    Response example

    [
      {
        "id": "bn:03083790n",
        "pos": "NOUN",
        "source": "BABELNET"
      }
    ]

    Code samples

    import urllib2
    import urllib
    import json
    import gzip
    
    from StringIO import StringIO
    
    service_url = 'https://babelnet.io/v4/getSynsetIdsFromResourceID'
    
    id      = 'BabelNet'
    lang    = 'EN'
    pos     = 'NOUN'
    source  = 'WIKI'
    key 	= 'KEY'
    
    params = {
            'id'     : id,
            'lang'   : lang,
            'pos'    : pos,
            'source' : source,
            'key'    : key
    }
    
    url = service_url + '?' + urllib.urlencode(params)
    request = urllib2.Request(url)
    request.add_header('Accept-encoding', 'gzip')
    response = urllib2.urlopen(request)
    
    if response.info().get('Content-Encoding') == 'gzip':
    	buf = StringIO( response.read())
    	f = gzip.GzipFile(fileobj=buf)
    	data = json.loads(f.read())
    	for result in data:
    		print result['id']
    
    require "net/http"
    require 'json'
    
    uri = URI("https://babelnet.io/v4/getSynsetIdsFromResourceID?")
    
    params = {
      :id     => 'BabelNet',
      :lang   => 'EN',
      :pos    => 'NOUN',
      :source => 'WIKI',
      :key    => 'KEY'
    }
    
    uri.query = URI.encode_www_form(params)
    
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    
    response = http.request(Net::HTTP::Get.new(uri.request_uri))
    
    if response.is_a?(Net::HTTPSuccess)
      json = JSON.parse(response.body)
      json.each do |entry|
        puts entry['id']
      end
    end
    <!DOCTYPE html>
    <html>
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    </head>
    <body>
    <script>
        var service_url = 'https://babelnet.io/v4/getSynsetIdsFromResourceID';
        var id      = 'BabelNet'
        var lang    = 'EN'
        var pos     = 'NOUN'
        var source  = 'WIKI'
        var key     = 'KEY'
    
        var params = {
            'id'     : id,
            'lang'   : lang,
            'pos'    : pos,
            'source' : source,
            'key'    : key
        };
    
        $.getJSON(service_url + "?", params, function(response) {
            $.each(response, function(key, val) {
                $('<div>', {text:val['id']}).appendTo(document.body);
            });
        });
    </script>
    </body>
    </html>
    <!DOCTYPE html>
    <html>
    <body>
    <?php
    
      $service_url = 'https://babelnet.io/v4/getSynsetIdsFromResourceID';
    
      $id     = 'BabelNet';
      $lang   = 'EN';
      $pos    = 'NOUN';
      $source = 'WIKI';
      $key    = 'KEY';
    
      $params = array(
        'word'     => $word,
        'lang'     => $lang,
        'pos'      => $pos,
        'source'   => $source,
        'key'      => $key
      );
    
      $url = $service_url . '?' . http_build_query($params);
    
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
      $response = json_decode(curl_exec($ch), true);
      curl_close($ch);
    
      foreach($response as $result) {
        echo $result['id'] . '<br/>';
      }
    ?>
    </body>
    </html>
    

    Retrieve edges of a given BabelNet synset

    Parameters

    Name Type Description
    id string Required. id of the synset you want to retrieve
    key string Required. API key obtained after signing up to BabelNet (see key & limits)

    Response example

    [
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00027425n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00044458n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "IT",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00045605n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00050901n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00020452n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:15812467n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:01178863n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00026967n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00049910n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00987447n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "IT",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00004785n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00025928n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "IT",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00027425n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00685308n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:02202384n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00010388n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:03217333n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "@w",
          "name": "Hypernym",
          "shortName": "is-a",
          "relationGroup": "HYPERNYM",
          "isAutomatic": true
        },
        "target": "bn:02275757n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "target": "bn:02275757n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00683882n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "target": "bn:00059033n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:02886551n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00031339n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "IT",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00052570n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00030862n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "@wd",
          "name": "Hypernym",
          "shortName": "is-a",
          "relationGroup": "HYPERNYM",
          "isAutomatic": false
        },
        "target": "bn:02290297n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "IT",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:02612327n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:17317913n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00054468n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:16847651n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00075730n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:03335629n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00045156n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00004786n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00050161n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00075735n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00045605n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "IT",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00046139n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00081546n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00064421n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00021547n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00000657n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:03288118n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "IT",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00031339n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "IT",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00597954n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:03335263n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00790971n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:00024746n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "target": "bn:01801234n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      },
      {
        "language": "EN",
        "pointer": {
          "fSymbol": "r",
          "name": "Semantically related form",
          "shortName": "related",
          "relationGroup": "OTHER",
          "isAutomatic": false
        },
        "target": "bn:03388996n",
        "weight": 0.0,
        "normalizedWeight": 0.0
      }
    ]

    Code samples

    import urllib2
    import urllib
    import json
    import gzip
    
    from StringIO import StringIO
    
    service_url = 'https://babelnet.io/v4/getEdges'
    
    id = 'bn:03083790n'
    key  = 'KEY'
    
    params = {
    	'id' : id,
    	'key'  : key
    }
    
    url = service_url + '?' + urllib.urlencode(params)
    request = urllib2.Request(url)
    request.add_header('Accept-encoding', 'gzip')
    response = urllib2.urlopen(request)
    
    if response.info().get('Content-Encoding') == 'gzip':
    	buf = StringIO( response.read())
    	f = gzip.GzipFile(fileobj=buf)
    	data = json.loads(f.read())
    
    	# retrieving Edges data
    	for result in data:
    		target = result.get('target')
    		language = result.get('language')
    
    		# retrieving BabelPointer data
    		pointer = result['pointer']
    		relation = pointer.get('name')
    		group = pointer.get('relationGroup')
    
    		print language.encode('utf-8') \
    		  + "\t" + str(target.encode('utf-8')) \
    		  + "\t" + str(relation.encode('utf-8')) \
    		  + "\t" + str(group.encode('utf-8'))
    
    require "net/http"
    require 'json'
    
    uri = URI("https://babelnet.io/v4/getEdges?")
    
    params = {
      :id => 'bn:14792761n',
      :key  => 'KEY'
    }
    
    uri.query = URI.encode_www_form(params)
    
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    
    response = http.request(Net::HTTP::Get.new(uri.request_uri))
    
    if response.is_a?(Net::HTTPSuccess)
      json = JSON.parse(response.body)
    
      # retrieving Edges data
      json.each do |entry|
        target = entry['target']
        language = entry['language']
    
        # retrieving BabelPointer data
        pointer = entry['pointer']
        relation = pointer['name']
        group = pointer['relationGroup']
    
        puts language + "\t" + target + "\t" + relation + "\t" + group
      end
    
    end
    <!DOCTYPE html>
    <html>
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    </head>
    <body>
    <script>
        var service_url = 'https://babelnet.io/v4/getEdges';
        var id = 'bn:14792761n'
        var key = 'KEY'
    
        var params = {
            'id': id,
            'key' : key
        };
    
        $.getJSON(service_url + "?", params, function(response) {
    
            $.each(response, function(key, val) {
                var pointer = val['pointer'];
                var entry = "Language: " + val['language']
                    + "<br/>Target: " + val['target']
                    + "<br/>Relation: " + pointer['name']
                    + "<br/>Relation group: " + pointer['relationGroup'] + "<br/><br/>";
                $('<div>', {html:entry}).appendTo(document.body);
            });
    
        });
    </script>
    </body>
    </html>
    <!DOCTYPE html>
    <html>
    <body>
    <?php
    
      $service_url = 'https://babelnet.io/v4/getEdges';
    
      $id = 'bn:03083790n';
      $key  = 'KEY';
    
      $params = array(
        'id'  => $id,
        'key' => $key
      );
    
      $url = $service_url . '?' . http_build_query($params);
    
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
      $response = json_decode(curl_exec($ch), true);
      curl_close($ch);
    
      # retrieving edges data
      foreach($response as $result) {
        $target = $result['target'];
        $language = $result['language'];
    
        $pointer = $result['pointer'];
        $relation = $pointer['name'];
        $group = $pointer['relationGroup'];
        echo "Language: " . $language
            . "<br/>Target: " . $target
            . "<br/>Relation: " . $relation
            . "<br/>Relation group: " . $group . "<br/><br/>";
      }
    
    ?>
    </body>
    </html>
    

    Retrieve hypernyms, hyponyms and antonyms of a given BabelNet synset

    import urllib2
    import urllib
    import json
    import gzip
    
    from StringIO import StringIO
    
    service_url = 'https://babelnet.io/v4/getEdges'
    
    id = 'bn:00007287n'
    key  = 'KEY'
    
    params = {
    	'id' : id,
    	'key'  : key
    }
    
    url = service_url + '?' + urllib.urlencode(params)
    request = urllib2.Request(url)
    request.add_header('Accept-encoding', 'gzip')
    response = urllib2.urlopen(request)
    
    if response.info().get('Content-Encoding') == 'gzip':
    	buf = StringIO( response.read())
    	f = gzip.GzipFile(fileobj=buf)
    	data = json.loads(f.read())
    
    	# retrieving Edges data
    	for result in data:
    		target = result.get('target')
    		language = result.get('language')
    
    		# retrieving BabelPointer data
                    pointer = result['pointer']
                    relation = pointer.get('name')
                    group = pointer.get('relationGroup')
    
                    # Types of relationGroup: HYPERNYM,  HYPONYM, MERONYM, HOLONYM, OTHER
                    if ('hypernym' in group.lower() or 'hyponym' in group.lower()):
                            print (str(language) + "\t" + str(target) + "\t" + str(relation) + "\t" + str(group))
                    elif ('antonym' in relation.lower()):
                            print (str(language) + "\t" + str(target) + "\t" + str(relation) + "\t" + str(group))
    
    
    require "net/http"
    require 'json'
    
    uri = URI("https://babelnet.io/v4/getEdges?")
    
    params = {
      :id => 'bn:00007287n',
      :key  => 'KEY'
    }
    
    uri.query = URI.encode_www_form(params)
    
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    
    response = http.request(Net::HTTP::Get.new(uri.request_uri))
    
    if response.is_a?(Net::HTTPSuccess)
      json = JSON.parse(response.body)
    
      # retrieving Edges data
      json.each do |entry|
        target = entry['target']
        language = entry['language']
    
        # retrieving BabelPointer data
        pointer = entry['pointer']
        relation = pointer['name']
        group = pointer['relationGroup']
    
        # Types of relationGroup: HYPERNYM,  HYPONYM, MERONYM, HOLONYM, OTHER
        if group.downcase.include? "hypernym" or group.downcase.include? "hyponym"
            puts language + "\t" + target + "\t" + relation + "\t" + group
        elsif relation.downcase.include? "antonym"
            puts language + "\t" + target + "\t" + relation + "\t" + group
        end
      end
    
    end
    <!DOCTYPE html>
    <html>
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    </head>
    <body>
    <script>
        var service_url = 'https://babelnet.io/v4/getEdges';
        var id = 'bn:00007287n'
        var key = 'KEY'
    
        var params = {
            'id': id,
    	'key' : key
        };
    
        $.getJSON(service_url + "?", params, function(response) {
    
            $.each(response, function(key, val) {
    
            var pointer = val['pointer'];
    	    var relation = pointer['name'];
    	    var group = pointer['relationGroup'];
    
            # Types of relationGroup: HYPERNYM,  HYPONYM, MERONYM, HOLONYM, OTHER
    	    if ((group.toLowerCase().indexOf("hypernym") > -1)
    		|| (group.toLowerCase().indexOf("hyponym") > -1)
    		|| (relation.toLowerCase().indexOf("antonym") > -1)) {
    		var entry = "Language: " + val['language']
    		    + "<br/>Target: " + val['target']
    		    + "<br/>Relation: " + relation
    		    + "<br/>Relation group: " + group + "<br/><br/>";
    		$('<div>', {html:entry}).appendTo(document.body);
    	    }
            });
    
        });
    </script>
    </body>
    </html>
    <!DOCTYPE html>
    <html>
    <body>
    <?php
    
      $service_url = 'https://babelnet.io/v4/getEdges';
    
      $id = 'bn:00007287n';
      $key  = 'KEY';
    
      $params = array(
        'id'  => $id,
        'key' => $key
      );
    
      $url = $service_url . '?' . http_build_query($params);
    
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
      $response = json_decode(curl_exec($ch), true);
      curl_close($ch);
    
      # retrieving edges data
      foreach($response as $result) {
        $target = $result['target'];
        $language = $result['language'];
    
        $pointer = $result['pointer'];
        $relation = $pointer['name'];
        $group = $pointer['relationGroup'];
    
        # Types of relationGroup: HYPERNYM,  HYPONYM, MERONYM, HOLONYM, OTHER
        if ((strpos(strtolower($group), "hypernym") !== FALSE)
    	    || (strpos(strtolower($group), "hyponym") !== FALSE)
    	    || (strpos(strtolower($relation), "antonym") !== FALSE)) {
    
    		echo "Language: " . $language
    		    . "<br/>Target: " . $target
    		    . "<br/>Relation: " . $relation
    		    . "<br/>Relation group: " . $group . "<br/><br/>";
        }
      }
    
    
    ?>
    </body>
    </html>
    

    HTTP request error

    Below, an example of an error message returned after a wrong call:

    Response example

    HTTP/1.1 400 Bad Request
    Content-Length: 52
    
    {"message":"Wrong parameters."}
    

    Related Project

    • BabelNet.js - a wrapper for the BabelNet HTTP API to be used from the browser and from Node.js.
  • Java API

    The BabelNet Java API requires JRE 1.7 or above.

    NOTE: Since the BabelNet 3.5 release, any data retrieved with the API is by default only in the search language. Should one want to retrieve other languages, it is possible to use the specific parameter Collection<Language> filterLangs present in the most important API methods. It is not possible to retrieve more than three languages other than the search language. For more details see this example.

    Here you can access the javadoc for the API. To work with the Java API, unpack the zip file with:

    unzip BabelNet-API-3.7.zip

    The file is available the download section.

    Configuration

    The first important step is the configuration of the properties files located inside the BabelNet API folder.

    For instance, assuming you received by email the following key (see key & limits): abcdefghilmnopqrstuvz

    1. Edit the babelnet.var.properties files inside BabelNet-API-3.7/config/

    Add the following line into babelnet.var.properties:

    babelnet.key=abcdefghilmnopqrstuvz

    Running the BabelNet demo

    Now, you can test that everything works simply issuing the run-babelnetdemo command within the main BabelNet-API folder. Otherwise, you can start the demo with the command line:

    java -classpath lib/*:babelnet-api-3.7.jar:config it.uniroma1.lcl.babelnet.demo.BabelNetDemo

    NOTE: If you are running out of Java heap space, you will need to add an argument like -Xmx1024M on your java command line:

    java -Xmx1024M -classpath lib/*:babelnet-api-3.7.jar:config it.uniroma1.lcl.babelnet.demo.BabelNetDemo

    Working with Eclipse and Netbeans

    In order to use the BabelNet API within an Eclipse or Netbeans project, you need to carry out the following steps (select either Eclipse or Netbeans):

    For Scala users: install the Scala plugin for Eclipse or download the Scala IDE for Eclipse - http://scala-ide.org/

    For Groovy users: install the Groovy plugin for Eclipse!

    1. Create your Eclipse project (File -> New -> Java (or Scala) project, give the project a name and press Finish). This creates a new folder with the project name under your Eclipse workspace folder
    2. Copy the config/ and resources/ folders from the BabelNet-API-3.7 folder into your workspace/projectFolder/
    3. Now we need to include all the lib/*.jar files and the babelnet-api-3.7.jar file in the project build classpath:
      1. Select the project from Package Explorer tree view
      2. From the top bar click on Project and then Properties
      3. Once inside the Properties section click on Java build path and select the Libraries tab
      4. From the right menu click on the Add External JARs button
      5. Browse to the downloaded BabelNet-API-3.7 folder, and select all the lib/*.jar files along with the babelnet-api-3.7.jar file
    4. Next we need to Include the config/ folder in the project build classpath:
      1. Select the project from Package Explorer tree view
      2. From the top bar click on File and then Refresh
      3. From the Java build path (see point 3 above) select the Source tab
      4. Once in the Source tab, click on Add Folder from the right sidebar and select the downloaded config/ folder
    5. Happy coding!! ;-)

    For Scala users: install the Scala plugin for Netbeans - http://wiki.netbeans.org/Scala

    For Groovy users: install the Groovy plugin for Netbeans!

    1. Create your Netbeans project (File -> New Project -> Java (or Scala), give the project a name and press Finish). This creates a new folder with the project name under your NetBeans workspace folder
    2. Copy the config/ and resources/ folders from the BabelNet-API-3.7 folder into your projectFolder/
    3. Now we need to include all the lib/*.jar files and the babelnet-api-3.7.jar file, along with the config/ folder in the project build classpath:
      1. Right click on the name of the project in the left tree view, click on Properties and then click on Categories
      2. Once in the Categories section select Libraries and click on the compiles button where you can add JARs and folders through the Add JAR/Folder button
      3. Browse to the downloaded BabelNet folder, and select all the lib/*.jar files along with the babelnet-api-3.7.jar file
      4. Next select the config/ folder and add that as well
    4. Happy coding!! ;-)

    Code

    Let's now look at the main classes in the BabelNet API. For more details, see the API javadoc.

    Main classes

    The main classes of BabelNet are:

    • BabelNet (the entry point to BabelNet)
    • BabelSynset (a concept or named entity identified by a set of multilingual lexicalizations (each being a BabelSense))
    • BabelSense (a lexicalization of a given concept (BabelSynset))

    BabelNet

    The BabelNet class is used as the entry point to access all the content available in BabelNet. The class is implemented through the singleton pattern, where we restrict the instantiation of the BabelNet class to one object. You can obtain a reference to the only instance of the BabelNet class with the following line:

    def bn = BabelNet.instanceval bn = BabelNet.getInstance()BabelNet bn = BabelNet.getInstance();

    Now you are ready to use the BabelNet object to work with the BabelNet API.

    BabelSynset

    A BabelSynset is a set of multilingual lexicalizations that are synonyms expressing a given concept or named entity. For instance, the synset for car in the motorcar sense looks like this. After creating the BabelNet object which we call bn, we can use its methods to retrieve one or many BabelSynset objects. For instance, to retrieve all the synsets containing car we can call the BabelNet#getSynset method:

    // Given a word in a certain language,
    // returns the concepts (`BabelSynsets`) denoted by the word.
    def byl = bn.getSynsets("car", Language.EN)// Given a word in a certain language,
    // returns the concepts (`BabelSynsets`) denoted by the word.
    val byl = bn.getSynsets("car", Language.EN)// Given a word in a certain language,
    // returns the concepts (`BabelSynsets`) denoted by the word.
    List<BabelSynset> byl = bn.getSynsets("car", Language.EN);

    We can also specify which of the parts of speech we are interested in and obtain only synsets for the specified part of speech. In the following example we retrieve all the verbal synsets containing the English lexicalization run:

    // Given a word in a certain language and pos (part of speech),
    // returns the concepts denoted by the word.
    def byl = bn.getSynsets("run", Language.EN, BabelPOS.VERB)// Given a word in a certain language and pos (part of speech),
    // returns the concepts denoted by the word.
    val byl = bn.getSynsets("run", Language.EN, BabelPOS.VERB)// Given a word in a certain language and pos (part of speech),
    // returns the concepts denoted by the word.
    List<BabelSynset> byl = bn.getSynsets("run", Language.EN, BabelPOS.VERB);
    

    The full list of BabelPOS values is:

    public enum BabelPOS
    {
     NOUN,
     ADJECTIVE,
     VERB,
     ADVERB,
     INTERJECTION,
     PREPOSITION,
     ARTICLE,
     DETERMINER,
     CONJUNCTION,
     PRONOUN;
    }

    However, as of version 3.0, only the open-class (i.e., top 4) parts of speech are available.

    Due to the nature of BabelNet, a BabelSynset may contain lexicalizations from different sources. You can restrict your search only to your sources of interest. For instance:

    // Given a word in a certain language, returns the concepts
    // for the word available in the given sense sources.
    def byl = bn.getSynsets("run", Language.EN, BabelPOS.NOUN, BabelSenseSource.WIKI, BabelSenseSource.OMWIKI)// Given a word in a certain language, returns the concepts
    // for the word available in the given sense sources.
    val byl = bn.getSynsets("run", Language.EN, BabelPOS.NOUN, BabelSenseSource.WIKI, BabelSenseSource.OMWIKI)// Given a word in a certain language, returns the concepts
    // for the word available in the given sense sources.
    List<BabelSynset> byl = bn.getSynsets("run", Language.EN, BabelPOS.NOUN, BabelSenseSource.WIKI, BabelSenseSource.OMWIKI);
    

    The full list of sources is:

    public enum BabelSenseSource
    {
        BABELNET,    // BabelNet senses, not available as of version 3.0
        WN,          // WordNet senses
        OMWN,        // Open Multilingual WordNet
        WONEF,       // WordNet du Francais
        WIKI,        // Wikipedia page
        WIKIDIS,     // Wikipedia disambiguation pages
        WIKIDATA,    // Wikidata senses
        OMWIKI,      // OmegaWiki senses
        WIKICAT,     // Wikipedia category, not available as of version 3.0
        WIKIRED,     // Wikipedia redirections
        WIKT,        // Wiktionary senses
        WIKIQU,      // Wikiquote page
        WIKIQUREDI,  // Wikiquote redirections
        WIKTLB,      // Wiktionary translation label
        VERBNET,	 // VerbNet senses
        FRAMENET,	 // FrameNet senses
        MSTERM,      // Microsoft Terminology items
        GEONM,       // GeoNames items
        WNTR,        // Translations of WordNet senses
        WIKITR       // Translations of Wikipedia links
    }

    Each BabelSynset has an ID that univocally identifies the synset and that can be obtained via the BabelSynset#getId method. If we have an ID and want to retrieve the corresponding synset, we can use the overloaded BabelNet#getSynset method. For instance:

    // Gets a BabelSynset from a concept identifier (Babel synset ID).
    def by = bn.getSynset(new BabelSynsetID("bn:03083790n"))// Gets a BabelSynset from a concept identifier (Babel synset ID).
    val by = bn.getSynset(new BabelSynsetID("bn:03083790n"))// Gets a BabelSynset from a concept identifier (Babel synset ID).
    BabelSynset by = bn.getSynset(new BabelSynsetID("bn:03083790n"));
    

    returns the BabelSynset corresponding to ID bn:03083790n, that is, the synset about BabelNet.

    If we want to retrieve the BabelSynset corresponding to a given WordNet 3.0 ID, we can use another overloaded version of the BabelNet#getSynset method:

    // Gets the BabelSynsets corresponding to an input WordNet offset.
    def by = bn.getSynset(new WordNetSynsetID("wn:06879521n"))// Gets the BabelSynsets corresponding to an input WordNet offset.
    val by = bn.getSynset(new WordNetSynsetID("wn:06879521n"))// Gets the BabelSynsets corresponding to an input WordNet offset.
    BabelSynset by = bn.getSynset(new WordNetSynsetID("wn:06879521n"));
    

    If we want to retrieve the BabelSynset corresponding to a given WordNet old version ID, we can use another overloaded version of the BabelNet#getSynset method:

    // Gets the BabelSynsets corresponding to an input WordNet offset of the version 2.1.
    def by = bn.getSynset(new WordNetSynsetID("wn:06303048n", WordNetVersion.WN_21))// Gets the BabelSynsets corresponding to an input WordNet offset of the version 2.1.
    val by = bn.getSynset(new WordNetSynsetID("wn:06303048n", WordNetVersion.WN_21))// Gets the BabelSynsets corresponding to an input WordNet offset of the version 2.1.
    BabelSynset by = bn.getSynset(new WordNetSynsetID("wn:06303048n", WordNetVersion.WN_21));
    

    If we want to retrieve the BabelSynset corresponding to a given Wikidata page ID, we can use another overloaded version of the BabelNet#getSynset method:

    // Gets the BabelSynsets corresponding to an input Wikidata page ID.
    def by = bn.getSynset(new WikidataID("Q4837690"))// Gets the BabelSynsets corresponding to an input Wikidata page ID.
    val by = bn.getSynset(new WikidataID("Q4837690"))// Gets the BabelSynsets corresponding to an input Wikidata page ID.
    BabelSynset by = bn.getSynset(new WikidataID("Q4837690"));
    

    If we want to retrieve the BabelSynsets containing a given Wikipedia page title, we can use the method BabelNet#getSynsets:

    // Given a Wikipedia title, returns the BabelSynsets which contain it.
    def byl = bn.getSynsets(new WikipediaID("Men in Black (film 1997)", Language.IT, BabelPOS.NOUN))// Given a Wikipedia title, returns the BabelSynsets which contain it.
    val byl = bn.getSynsets(new WikipediaID("Men in Black (film 1997)", Language.IT, BabelPOS.NOUN))// Given a Wikipedia title, returns the BabelSynsets which contain it.
    List<BabelSynset> byl = bn.getSynsets(new WikipediaID("Men in Black (film 1997)", Language.IT, BabelPOS.NOUN));
    

    BabelSense

    A BabelSense is a term (either word or multi-word expression) in a given language occurring in a certain BabelSynset. Each occurrence of the same term (e.g., car) in different synsets is therefore a different BabelSense of that term.

    Now let's look at the methods to retrieve a BabelSense using the bn object we created earlier:

    // Returns the senses for the word in a certain language.
    def senses = bn.getSenses("home", Language.EN)
    
    // Returns the senses for the word in a certain language and Part-Of-Speech.
    def senses = bn.getSenses("run", Language.EN, BabelPOS.VERB)
    
    // Returns the senses for the word with the given constraints.
    def senses = bn.getSenses("run", Language.EN, BabelPOS.VERB, BabelSenseSource.WIKI, BabelSenseSource.OMWIKI)// Returns the senses for the word in a certain language.
    val senses = bn.getSenses("home", Language.EN)
    
    // Returns the senses for the word in a certain language and Part-Of-Speech.
    val senses = bn.getSenses("run", Language.EN, BabelPOS.VERB)
    
    // Returns the senses for the word with the given constraints.
    val senses = bn.getSenses("run", Language.EN, BabelPOS.VERB, BabelSenseSource.WIKI, BabelSenseSource.OMWIKI)// Returns the senses for the word in a certain language.
    List<BabelSense> senses = bn.getSenses("home", Language.EN);
    
    // Returns the senses for the word in a certain language and Part-Of-Speech.
    List<BabelSense> senses = bn.getSenses("run", Language.EN, BabelPOS.VERB);
    
    // Returns the senses for the word with the given constraints.
    List<BabelSense> senses = bn.getSenses("run", Language.EN, BabelPOS.VERB, BabelSenseSource.WIKI, BabelSenseSource.OMWIKI);
    

    Once we have a BabelSense, we can go back to the synset it belongs to using the BabelSense#getSynset method:

    BabelSynset by = sense.synsetval by: BabelSynset = sense.getSynset()BabelSynset by = sense.getSynset();
    

    We can view the BabelSynset as a container of BabelSenses, i.e., the lexicalizations in the various languages contained in the synset that express its concept or named entity.

    Some methods of BabelSynset and BabelSense

    We are now going into details about important methods of the BabelSynset and BabelSense classes.

    Main BabelSynset methods

    BabelSynset is composed of various elements which we describe below. Furthermore, a BabelSynset is connected to other BabelSynset objects. The main components of a BabelSynset are objects of the following types:

    1. BabelSense (a lexicalization of the concept, see above)
    2. BabelPOS (the synset's part of speech)
    3. BabelGloss (a definition of the concept in a given language)
    4. BabelExample (an example sentence of the meaning expressed by the synset)
    5. BabelImage (an image depicting the concept)
    6. BabelSynsetIDRelation (an edge semantically connecting the synset to another synset)

    Let's take a look at the main methods of a BabelSynset object which we call by. Note: to obtain BabelSynset objects we can also use the above examples.

    // Gets a BabelSynset from a concept identifier (Babel synset ID).
    BabelSynset by = bn.getSynset(new BabelSynsetID("bn:03083790n"))
    
    // Most relevant BabelSense to this BabelSynset for a given language.
    BabelSense bs = by.getMainSense(Language.EN)
    
    // Gets the part of speech of this BabelSynset.
    BabelPOS pos = by.POS
    
    // True if the BabelSynset is a key concept
    boolean iskeyConcept = by.isKeyConcept();
    
    // Gets the senses contained in this BabelSynset.
    List<BabelSense> senses = by.senses
    
    // Collects all BabelGlosses in the given source for this BabelSynset.
    List<BabelGloss> glosses = by.glosses
    
    // Collects all BabelExamples for this BabelSynset.
    List<BabelExample> examples = by.examples
    
    // Gets the images (BabelImages) of this BabelSynset.
    List<BabelImage> images = by.images
    
    // Collects all the edges incident on this BabelSynset.
    List<BabelSynsetIDRelation> edges = by.edges
    
    // Gets the BabelCategory objects of this BabelSynset.
    List<BabelCategory> cats = by.categories
    
    // Gets a BabelSynset from a concept identifier (Babel synset ID).
    val by: BabelSynset = bn.getSynset(new BabelSynsetID("bn:03083790n"))
    
    // Most relevant BabelSense to this BabelSynset for a given language.
    val bs: BabelSense = by.getMainSense(Language.EN)
    
    // Gets the part of speech of this BabelSynset.
    val pos: BabelPOS = by.getPOS()
    
    // True if the BabelSynset is a key concept
    val iskeyConcept = by.isKeyConcept();
    
    // Gets the senses contained in this BabelSynset.
    val senses: java.util.List[BabelSense] = by.getSenses()
    
    // Collects all BabelGlosses in the given source for this BabelSynset.
    val glosses: java.util.List[BabelGloss] = by.getGlosses()
    
    // Collects all BabelExamples for this BabelSynset.
    val examples: java.util.List[BabelExample] = by.getExamples()
    
    // Gets the images (BabelImages) of this BabelSynset.
    val images: java.util.List[BabelImage] = by.getImages()
    
    // Collects all the edges incident on this BabelSynset.
    val edges: java.util.List[BabelSynsetIDRelation] = by.getEdges()
    
    // Gets the BabelCategory objects of this BabelSynset.
    val cats: java.util.List[BabelCategory] = by.getCategories()// Gets a BabelSynset from a concept identifier (Babel synset ID).
    BabelSynset by = bn.getSynset(new BabelSynsetID("bn:03083790n"));
    
    // Most relevant BabelSense to this BabelSynset for a given language.
    BabelSense bs = by.getMainSense(Language.EN);
    
    // Gets the part of speech of this BabelSynset.
    BabelPOS pos = by.getPOS();
    
    // True if the BabelSynset is a key concept
    boolean iskeyConcept = by.isKeyConcept();
           
    // Gets the senses contained in this BabelSynset.
    List<BabelSense> senses = by.getSenses();
    
    // Collects all BabelGlosses in the given source for this BabelSynset.
    List<BabelGloss> glosses = by.getGlosses();
    
    // Collects all BabelExamples for this BabelSynset.
    List<BabelExample> examples = by.getExamples();
    
    // Gets the images (BabelImages) of this BabelSynset.
    List<BabelImage> images = by.getImages();
    
    // Collects all the edges incident on this BabelSynset.
    List<BabelSynsetIDRelation> edges = by.getEdges();
    
    // Gets the BabelCategory objects of this BabelSynset.
    List<BabelCategory> cats = by.getCategories();

    Main BabelSense methods

    We now have a look at the BabelSense methods. The main components of a BabelSense are:

    1. BabelSynset (the synset the sense belongs to)
    2. BabelPOS (its part-of-speech tag)
    3. the lemma string (the lexicalization of the sense)
    4. BabelSensePhonetics (the written and audio pronunciations of this sense)
    5. BabelSenseSource (the source of the sense, e.g.: Wikipedia, WordNet, etc., see above)

    Some code retrieving the above information follows:

    BabelSense bs = by.getMainSense(Language.EN)
    
    // Gets the language of this BabelSense
    Language lang = bs.language
    
    // Gets the part-of-speech tag of this BabelSense
    BabelPOS pos = bs.POS
    
    // True if the BabelSense is a key concept
    boolean iskeyConcept = bs.isKeyConcept();
    
    // Gets the lemma of this BabelSense
    String lemma = bs.lemma
    
    // Gets the simple lemma of this sense (i.e., without parentheses, etc.)
    String simpleLemma = bs.simpleLemma
    
    // Gets the pronunciations of this sense
    BabelSensePhonetics pronunciations = bs.pronunciations
    
    // Collects all the sources of the sense; ex: Wikipedia, WordNet, etc.
    BabelSenseSource source = bs.sourceval bs: BabelSense = by.getMainSense(Language.EN)
    
    // Gets the language of this BabelSense
    val lang = bs.getLanguage()
    
    // Gets the part-of-speech tag of this BabelSense
    val pos: BabelPOS = bs.getPOS()
    
    // True if the BabelSense is a key concept
    val iskeyConcept = bs.isKeyConcept();
    
    // Gets the lemma of this BabelSense
    val lemma: String = bs.getLemma()
    
    // Gets the simple lemma of this sense (i.e., without parentheses, etc.)
    val simpleLemma: String = bs.getSimpleLemma()
    
    // Gets the pronunciations of this sense
    val pronunciations: BabelSensePhonetics = bs.getPronunciations()
    
    // Collects all the sources of the sense; ex: Wikipedia, WordNet, etc.
    val source: BabelSenseSource = bs.getSource()BabelSense bs = by.getMainSense(Language.EN);
    
    // Gets the language of this BabelSense
    Language lang = bs.getLanguage();
    
    // Gets the part-of-speech tag of this BabelSense
    BabelPOS pos = bs.getPOS();
    
    // True if the BabelSense is a key concept
    boolean iskeyConcept = bs.isKeyConcept();
    
    // Gets the lemma of this BabelSense
    String lemma = bs.getLemma();
    
    // Gets the simple lemma of this sense (i.e., without parentheses, etc.)
    String simpleLemma = bs.getSimpleLemma();
    
    // Gets the pronunciations of this sense
    BabelSensePhonetics pronunciations = bs.getPronunciations();
    
    // Collects all the sources of the sense; ex: Wikipedia, WordNet, etc.
    BabelSenseSource source = bs.getSource();
    

    Usage examples

    Here we show full examples that show how you can use the BabelNet API to accomplish several tasks.

    Retrieve all BabelSynset objects for a specific word

    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.jlt.util.Language
    
    class Example {
        static void main(def args) throws IOException {
            def bn = BabelNet.instance
            for (synset in bn.getSynsets("home", Language.EN)) {
                println("Synset ID: ${synset.id}")
            }
        }
    }import scala.collection.JavaConversions._
    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.jlt.util.Language
    
    object Example extends App {
        val bn = BabelNet.getInstance()
        for (synset <- bn.getSynsets("home", Language.EN))
            System.out.println("Synset ID: " + synset.getId())
    }import it.uniroma1.lcl.babelnet.BabelNet;
    import it.uniroma1.lcl.babelnet.BabelSynset;
    import it.uniroma1.lcl.jlt.util.Language;
    import java.io.IOException;
    
    public class Example {
        public static void main(String[] args) throws IOException {
            BabelNet bn = BabelNet.getInstance();
            for (BabelSynset synset : bn.getSynsets("home", Language.EN)) {
                System.out.println("Synset ID: " + synset.getId());
            }
        }
    }
    

    For a specific word retrieves all BabelSynset objects in English, Italian and French.

    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.jlt.util.Language
    
    class Example {
        static void main(def args) throws IOException {
            def bn = BabelNet.instance
            for (synset in bn.getSynsets("home", Language.EN, Arrays.asList(Language.IT, Language.FR))) {
                println("Synset ID: ${synset.id}")
            }
        }
    }import scala.collection.JavaConversions._
    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.jlt.util.Language
    
    object Example extends App {
        val bn = BabelNet.getInstance()
        for (synset <- bn.getSynsets("home", Language.EN, Arrays.asList(Language.IT, Language.FR)))
            System.out.println("Synset ID: " + synset.getId())
    }import it.uniroma1.lcl.babelnet.BabelNet;
    import it.uniroma1.lcl.babelnet.BabelSynset;
    import it.uniroma1.lcl.jlt.util.Language;
    import java.io.IOException;
    import java.util.Arrays;
    
    public class Example {
        public static void main(String[] args) throws IOException {
            BabelNet bn = BabelNet.getInstance();
            for (BabelSynset synset : bn.getSynsets("home", Language.EN, Arrays.asList(Language.IT, Language.FR))) {
                System.out.println("Synset ID: " + synset.getId());
            }
        }
    }
    

    Retrieve all BabelSense objects for a specific BabelSynset object

    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.babelnet.BabelSynsetID
    
    class Example {
        static void main(def args) throws IOException {
            def bn = BabelNet.instance
            for (sense in bn.getSynset(new BabelSynsetID("bn:00000356n"))) {
                println "Sense: ${sense.lemma}" +
                        "\tLanguage: ${sense.language}" +
                        "\tSource: ${sense.source}"
    
                def phonetic = sense.pronunciations
                for (audio in phonetic.audioItems) {
                    println("Audio URL ${audio.validatedUrl}");
                }
            }
        }
    }import scala.collection.JavaConversions._
    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.babelnet.BabelSynsetID
    
    object Example extends App {
        val bn = BabelNet.getInstance()
        for (sense <- bn.getSynset(new BabelSynsetID("bn:00000356n"))) {
            println("Sense: " + sense.getLemma()
                    + "\tLanguage: " + sense.getLanguage().toString()
                    + "\tSource: " + sense.getSource().toString())
            val phonetic = sense.getPronunciations()
            for (audio <- phonetic.getAudioItems()) {
                println("Audio URL " + audio.getValidatedUrl())
            }
        }
    }import it.uniroma1.lcl.babelnet.BabelNet;
    import it.uniroma1.lcl.babelnet.BabelSynsetID;
    import it.uniroma1.lcl.babelnet.InvalidBabelSynsetIDException;
    import it.uniroma1.lcl.babelnet.data.BabelAudio;
    import it.uniroma1.lcl.babelnet.data.BabelSense;
    import it.uniroma1.lcl.babelnet.data.BabelSensePhonetics;
    import java.io.IOException;
    
    public class Example {
        public static void main(String[] args) throws IOException, InvalidBabelSynsetIDException {
            BabelNet bn = BabelNet.getInstance();
            for (BabelSense sense : bn.getSynset(new BabelSynsetID("bn:00000356n"))) {
                System.out.println("Sense: " + sense.getLemma()
                                + "\tLanguage: " + sense.getLanguage().toString()
                                + "\tSource: " + sense.getSource().toString());
                BabelSensePhonetics phonetic = sense.getPronunciations();
                for (BabelAudio audio : phonetic.getAudioItems()) {
                    System.out.println("Audio URL " + audio.getValidatedUrl());
                }
            }
        }
    }
    

    Retrieve all BabelSense objects for a specific Wikidata page id

    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.babelnet.resources.WikidataID
    
    class Example {
        static void main(def args) throws IOException {
            def bn = BabelNet.instance
            for (sense in bn.getSynset(new WikidataID("Q4837690"))) {
                println "Sense: " +
                        "\tLanguage: " +
                        "\tSource: "
    
                def phonetic = sense.pronunciations
                for (audio in phonetic.audioItems) {
                    println("Audio URL ");
                }
            }
        }
    }import scala.collection.JavaConversions._
    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.babelnet.resources.WikidataID
    
    object Example extends App {
        val bn = BabelNet.getInstance()
        for (sense <- bn.getSynset(new WikidataID("Q4837690"))) {
            println("Sense: " + sense.getLemma()
                    + "\tLanguage: " + sense.getLanguage().toString()
                    + "\tSource: " + sense.getSource().toString())
            val phonetic = sense.getPronunciations()
            for (audio <- phonetic.getAudioItems()) {
                println("Audio URL " + audio.getValidatedUrl())
            }
        }
    }import java.io.IOException;
    import it.uniroma1.lcl.babelnet.BabelNet;
    import it.uniroma1.lcl.babelnet.data.BabelSense;
    import it.uniroma1.lcl.babelnet.data.BabelAudio;
    import it.uniroma1.lcl.babelnet.data.BabelSensePhonetics;
    import it.uniroma1.lcl.babelnet.resources.WikidataID;
    
    
    public class Example {
        public static void main(String[] args) throws IOException {
            BabelNet bn = BabelNet.getInstance();
            for (BabelSense sense : bn.getSynset(new WikidataID("Q4837690"))) {
                System.out.println("Sense: " + sense.getLemma()
                                + "\tLanguage: " + sense.getLanguage().toString()
                                + "\tSource: " + sense.getSource().toString());
                BabelSensePhonetics phonetic = sense.getPronunciations();
                for (BabelAudio audio : phonetic.getAudioItems()) {
                    System.out.println("Audio URL " + audio.getValidatedUrl());
                }
            }
        }
    }
    

    Retrieve Wikidata id for each BabelSense in a BabelSynset

    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.babelnet.BabelSynsetID
    import it.uniroma1.lcl.babelnet.data.BabelSenseSource
    
    class Example {
        static void main(def args) throws IOException {
            def bn = BabelNet.instance
            def by = bn.getSynset(new BabelSynsetID("bn:00000288n"));
            for(sense in by.getSenses(BabelSenseSource.WIKIDATA)){
                def sensekey = sense.sensekey
                println "${sense.lemma}" +
                    "\t${sense.language}" +
                    "\t${sensekey}"
            }
        }
    }import scala.collection.JavaConversions._
    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.babelnet.BabelSynsetID
    import it.uniroma1.lcl.babelnet.data.BabelSenseSource;
    
    object Example extends App {
        val bn = BabelNet.getInstance()
        val by = bn.getSynset(new BabelSynsetID("bn:00000288n"))
        for (sense <- by.getSenses(BabelSenseSource.WIKIDATA))) {
            val sensekey = sense.getSensekey();
            println("Sense: " + sense.getLemma()
                    + "\tLanguage: " + sense.getLanguage().toString()
                    + "\tSensekey: " + sensekey)
        }
    }import it.uniroma1.lcl.babelnet.BabelNet;
    import it.uniroma1.lcl.babelnet.BabelNet;
    import it.uniroma1.lcl.babelnet.BabelSense;
    import it.uniroma1.lcl.babelnet.BabelSynset;
    import it.uniroma1.lcl.babelnet.BabelSynsetID;
    import it.uniroma1.lcl.babelnet.InvalidBabelSynsetIDException;
    import it.uniroma1.lcl.babelnet.data.BabelSenseSource;
    import java.io.IOException;
    
    public class Example {
        public static void main(String[] args) throws IOException, InvalidBabelSynsetIDException {
           BabelNet bn = BabelNet.getInstance();
           BabelSynset by = bn.getSynset(new BabelSynsetID("bn:00000288n"));
           for (BabelSense sense : by.getSenses(BabelSenseSource.WIKIDATA)) {
               String sensekey = sense.getSensekey();
               System.out.println(sense.getLemma() + "\t" + sense.getLanguage() + "\t" + sensekey);
           }
       }
    }
    

    Retrieve neighbors of a BabelSynset object

    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.babelnet.BabelSynsetID
    import it.uniroma1.lcl.jlt.util.Language
    
    class Example {
        static void main(def args) throws IOException {
            def bn = BabelNet.instance
            def by = bn.getSynset(new BabelSynsetID("bn:00044492n"));
            for(edge in by.edges) {
                println "${by.id}" +
                    "\t${by.getMainSense(Language.EN).lemma}" +
                    " - ${edge.pointer}" +
                    " - ${edge.babelSynsetIDTarget}"
            }
        }
    }import scala.collection.JavaConversions._
    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.babelnet.BabelSynsetID
    import it.uniroma1.lcl.jlt.util.Language
    
    object Example extends App {
        val bn = BabelNet.getInstance()
        val by = bn.getSynset(new BabelSynsetID("bn:00044492n"))
        for(edge <- by.getEdges()) {
            println(by.getId()+"\t"+by.getMainSense(Language.EN).getLemma()+" - "
                    + edge.getPointer()+" - "
                    + edge.getBabelSynsetIDTarget());
        }
    }import it.uniroma1.lcl.babelnet.BabelNet;
    import it.uniroma1.lcl.babelnet.BabelSynset;
    import it.uniroma1.lcl.babelnet.BabelSynsetID;
    import it.uniroma1.lcl.babelnet.BabelSynsetIDRelation;
    import it.uniroma1.lcl.babelnet.InvalidBabelSynsetIDException;
    import it.uniroma1.lcl.jlt.util.Language;
    
    import java.io.IOException;
    
    public class Example {
        public static void main(String[] args) throws IOException, InvalidBabelSynsetIDException {
            BabelNet bn = BabelNet.getInstance();
            BabelSynset by = bn.getSynset(new BabelSynsetID("bn:00044492n"));
            for(BabelSynsetIDRelation edge : by.getEdges()) {
                System.out.println(by.getId()+"\t"+by.getMainSense(Language.EN).getLemma()+" - "
                    + edge.getPointer()+" - "
                    + edge.getBabelSynsetIDTarget());
            }
        }
    }
    

    Retrieve all hypernyms of a BabelSynset object

    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.babelnet.BabelSynsetID
    import it.uniroma1.lcl.jlt.util.Language
    
    class Example {
        static void main(def args) throws IOException {
            def bn = BabelNet.instance
            def by = bn.getSynset(new BabelSynsetID("bn:00015556n"));
            for(edge in by.edges(BabelPointer.ANY_HYPERNYM)) {
                println "${by.id}" +
                    "\t${by.getMainSense(Language.EN).lemma}" +
                    " - ${edge.pointer}" +
                    " - ${edge.babelSynsetIDTarget}"
            }
        }
    }import scala.collection.JavaConversions._
    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.babelnet.BabelSynsetID
    import it.uniroma1.lcl.jlt.util.Language
    
    object Example extends App {
        val bn = BabelNet.getInstance()
        val by = bn.getSynset(new BabelSynsetID("bn:00015556n"))
        for(edge <- by.getEdges(BabelPointer.ANY_HYPERNYM)) {
            println(by.getId()+"\t"+by.getMainSense(Language.EN).getLemma()+" - "
                    + edge.getPointer()+" - "
                    + edge.getBabelSynsetIDTarget());
        }
    }import it.uniroma1.lcl.babelnet.BabelNet;
    import it.uniroma1.lcl.babelnet.BabelSynset;
    import it.uniroma1.lcl.babelnet.BabelSynsetID;
    import it.uniroma1.lcl.babelnet.BabelSynsetIDRelation;
    import it.uniroma1.lcl.babelnet.InvalidBabelSynsetIDException;
    import it.uniroma1.lcl.jlt.util.Language;
    
    import java.io.IOException;
    
    public class Example {
        public static void main(String[] args) throws IOException, InvalidBabelSynsetIDException {
            BabelNet bn = BabelNet.getInstance();
            BabelSynset by = bn.getSynset(new BabelSynsetID("bn:00015556n"));
            for(BabelSynsetIDRelation edge : by.getEdges(BabelPointer.ANY_HYPERNYM)) {
                System.out.println(by.getId()+"\t"+by.getMainSense(Language.EN).getLemma()+" - "
                    + edge.getPointer()+" - "
                    + edge.getBabelSynsetIDTarget());
            }
        }
    }
    

    Retrieve all surface forms of a BabelSynset object

    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.babelnet.BabelSynsetID
    import it.uniroma1.lcl.jlt.util.Language
    
    class Example {
        static void main(def args) throws IOException {
            def bn = BabelNet.instance
            def by = bn.getSynset(new BabelSynsetID("bn:00015556n"));
            for(form in by.getOtherForms(Language.EN)) {
                 println "${synset.getId}" +
                  	"\t${synset.getMainSense(Language.EN).getLemma()}" +
                  	"\t${form}"
            }
        }
    }import scala.collection.JavaConversions._
    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.babelnet.BabelSynsetID
    import it.uniroma1.lcl.jlt.util.Language
    
    object Example extends App {
        val bn = BabelNet.getInstance()
        val by = bn.getSynset(new BabelSynsetID("bn:00015556n"))
        for(form <- by.getOtherForms(Language.EN)) {
            println(by.getId()+"\t"+by.getMainSense(Language.EN).getLemma()+" - "
                    + form);
        }
    }import java.io.IOException;
    import java.util.Map;
    import java.util.Spliterator;
    import java.util.Spliterators;
    import java.util.function.Function;
    import java.util.stream.Collectors;
    import java.util.stream.Stream;
    import java.util.stream.StreamSupport;
    
    import it.uniroma1.lcl.babelnet.BabelNet;
    import it.uniroma1.lcl.babelnet.BabelSynset;
    
    public class Example {
        public static void main(String[] args) throws IOException, InvalidBabelSynsetIDException {
            BabelNet bn = BabelNet.getInstance();
            for(String form : by.getOtherForms(Language.EN)) {
                System.out.println(by.getId()+"\t"+by.getMainSense(Language.EN).getLemma()+" - "
                    + form);
            }
        }
    }
    

    Retrieve the distribution of relationships (frequency of each BabelPointer type) for a specific word

    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.jlt.util.Language
    
    class Example {
        static void main(def args) throws IOException {
            def bn = BabelNet.instance
            def synsets = bn.getSynsets("car", Language.EN)
            
            def totalByDept = synsets.collect { it.getEdges() }
                .flatten()
                .iterator()
                .countBy { it.getAt("pointer").getAt("symbol") }
            
            totalByDept.each { println "${it.getKey()}\t${it.getValue()}" }
        }
    }import scala.collection.JavaConversions._
    import it.uniroma1.lcl.babelnet.BabelNet
    import it.uniroma1.lcl.jlt.util.Language
    
    object Example extends App {
    
        val bn = BabelNet.getInstance
        val synsetsList = bn.getSynsets("car", Language.EN)
    
        val totalByDept = synsetsList.flatMap(synset => synset.getEdges)
            .map(edge => edge.getPointer.getSymbol)
            .groupBy(identity).mapValues(_.size)
    
        totalByDept.foreach(pointer => println(pointer._1 + "\t" + pointer._2))
    }import java.io.IOException;
    import java.util.List;
    import java.util.Map;
    import java.util.function.Function;
    import java.util.stream.Collectors;
    
    import it.uniroma1.lcl.babelnet.BabelNet;
    import it.uniroma1.lcl.babelnet.BabelSynset;
    import it.uniroma1.lcl.babelnet.InvalidBabelSynsetIDException;
    import it.uniroma1.lcl.jlt.util.Language;
    
    public class Example {
        public static void main(String[] args) throws IOException, InvalidBabelSynsetIDException {
    
            BabelNet bn = BabelNet.getInstance();
            List<BabelSynset> synsets = bn.getSynsets("car", Language.EN);
            
            Map<String, Long> totalByDept = synsets.parallelStream()
                .flatMap( synset ->  synset.getEdges().parallelStream())
                .map( edge -> edge.getPointer().getSymbol())
                .collect(Collectors.groupingByConcurrent(Function.identity(), Collectors.counting()));
            
            totalByDept.forEach((pointer, freq) -> System.out.println(pointer + "\t" + freq));
        }
    }
    

    Obtain a BabelNet Java instance in a webapp environment

    
    // The code supposes that the BabelNet "config/" and "resources/" folders are inside the "/WEB-INF/" folder of your web application.
    
    Configuration jltConfiguration = Configuration.getInstance();
    jltConfiguration.setConfigurationFile(new File(getServletContext().getRealPath("/") + "WEB-INF/config/jlt.properties"));
    
    BabelNetConfiguration bnconf = BabelNetConfiguration.getInstance();
    bnconf.setConfigurationFile(new File(getServletContext().getRealPath("/") + "/WEB-INF/config/babelnet.properties"));
    bnconf.setBasePath(getServletContext().getRealPath("/") + "/WEB-INF/");
    BabelNet bn =  BabelNet.getInstance();
    
    // your BabelNet code here
    

    SPARQL

    You can query BabelNet via our SPARQL endpoint or via our Linked Data interface.

    Data querying

    In order to grasp the real power of the resource, we will now introduce some concrete SPARQL queries. Despite their simplicity, the following queries model very common patterns in the industrial panorama. These can then be extended and customized to your specific needs with very little effort.

    Before you can run SPARQL queries you must obtain an API KEY by signing up here. You can then append the key parameter to the HTTP GET requests. Here is an example of a query: http://babelnet.org/sparql/?query=<your SPARQL query>&key=<your key>

    Retrieve the senses of a lemma for a certain language

    Given a word, e.g. home, retrieve all its senses and corresponding synsets in English:

     SELECT DISTINCT ?sense ?synset WHERE {
        ?entries a lemon:LexicalEntry .
        ?entries lemon:sense ?sense .
        ?sense lemon:reference ?synset .
        ?entries rdfs:label "home"@en .
    } LIMIT 10
    

    Retrieve the translations of a given sense

    Given a sense, we want to obtain all its translations: e.g., given the sense http://babelnet.org/rdf/home_EN/s00044488n:

     SELECT ?translation WHERE {
        <http://babelnet.org/rdf/home_EN/s00044488n> a lemon:LexicalSense ;
            lexinfo:translation ?translation .
    }
    

    Retrieve license information about a sense

    For instance, given the sense http://babelnet.org/rdf/home_EN/s00044488n:

     SELECT ?license WHERE {
        <http://babelnet.org/rdf/home_EN/s00044488n> a lemon:LexicalSense ;
            dcterms:license ?license .
    }
    

    Retrieve the resources to which sense information belong

    For instance, given the sense: http://babelnet.org/rdf/home_EN/s00044488n:

     SELECT ?source WHERE {
        <http://babelnet.org/rdf/home_EN/s00044488n> a lemon:LexicalSense ;
            dc:source ?source .
    }
    

    Retrieve the textual definitions of a given synset in all languages

    For instance, given the synset: http://babelnet.org/rdf/s00000356n:

     SELECT DISTINCT ?language ?gloss ?license ?sourceurl WHERE {
        <http://babelnet.org/rdf/s00000356n> a skos:Concept ;
            bn-lemon:synsetID ?synsetID .
        OPTIONAL {
            <http://babelnet.org/rdf/s00000356n> bn-lemon:definition ?definition .
            ?definition lemon:language ?language .
            ?definition bn-lemon:gloss ?gloss .
            ?definition dcterms:license ?license .
            ?definition dc:source ?sourceurl .
        }
    }
    

    Retrieve the textual definitions of a given synset in a certain language

    For instance, given the synset: http://babelnet.org/rdf/s00000356n:

     SELECT DISTINCT ?gloss ?license ?sourceurl WHERE {
        <http://babelnet.org/rdf/s00000356n> a skos:Concept ;
            bn-lemon:synsetID ?synsetID .
        OPTIONAL {
            <http://babelnet.org/rdf/s00000356n> bn-lemon:definition ?definition .
            ?definition lemon:language "EN" .
            ?definition bn-lemon:gloss ?gloss .
            ?definition dcterms:license ?license .
            ?definition dc:source ?sourceurl .
        }
    }
    

    Retrieve a synset's hyponyms

    For instance, given the synset: http://babelnet.org/rdf/s00000356n:

     SELECT ?narrower WHERE {
        <http://babelnet.org/rdf/s00000356n> a skos:Concept .
        OPTIONAL { <http://babelnet.org/rdf/s00000356n> skos:narrower ?narrower }
    }
    

    Retrieve a synset's hypernyms

    For instance, given the synset: http://babelnet.org/rdf/s00000356n:

     SELECT ?broader WHERE {
        <http://babelnet.org/rdf/s00000356n> a skos:Concept .
        OPTIONAL { <http://babelnet.org/rdf/s00000356n> skos:broader ?broader }
    }
    

    Retrieve all the RDF information of a synset

    For instance, given the synset http://babelnet.org/rdf/s00000356n:

     DESCRIBE <http://babelnet.org/rdf/s00000356n>
    

    How do I obtain a BabelNet API key?

    To obtain an API key you must register an account on BabelNet: http://babelnet.org/register. At the end of the registration process, you will receive an email with your API key. Information about how to use the API key is available on the HTTP API and Java API pages.

    What is a Babelcoin?

    Babelcoins are used as an internal credit system to keep track of the requests made against our APIs. 1 Babelcoin represents the ability to make 1 query against either the BabelNet or the new Babelfy API (available soon). For instance, if you have 187 Babelcoins left in your account, it means you can only perform 187 query requests. Note that your Babelcoins will be reset daily back to 1000 credits.

    How many Babelcoins are given with a base account?

    When you first register on BabelNet, you will be given 1000 Babelcoins per day.

    How can I increase the Babelcoins daily limit?

    We provide the possibility of increasing the Babelcoins daily limit (maximum is 50000 Babelcoins per day), normally set to 1000, to people wanting to use BabelNet for research purposes. You can make an increment request using the form in your private area of the BabelNet website (http://babelnet.org/login). Make sure you use an institutional email in your BabelNet account so we can verify the institute that is making the request.

    How can I download the BabelNet indices?

    (Size: 16Gb; because of space and memory requirements we discourage download unless necessary)

    If you are a researcher affiliated with a research institution and you need to use the BabelNet indices for your non commercial research project, you can make a request for downloading the indices using the form in your private area of the BabelNet website (http://babelnet.org/login).

    IMPORTANT: The email used in your BabelNet account registration must belong to your research institution.
    NOTE: Each request is subject to approval and fulfillment is based on the above conditions.

    How can I use BabelNet commercially?

    BabelNet is now a self-sustained project. It is, and always will be, free for research purposes, including download. Babelscape is BabelNet's commercial support arm, thanks to which the project will be continued and improved over time.