I'm trying to use the BabelNet restful API to retrieve the information on the page below the gloss and above the button that says "Explore Network". For example on the page for GPS I want to be able to extract these attribute value pairs:
IS A navigational system • sat nav • avionics
HAS PART USA-242 • USA-248
COUNTRY United States
COUNTRY OF ORIGIN United States
OPERATOR Air Force Space Command
USE location • place
Is that information available through the restful API?
Update:
I've actually more or less figured this out. The key is the getOutgoingEdges
query, though some parts of this are trial and error as I didn't find the documentation as helpful as one might hope. But here's what I've got (just printing them out for now for debug purposes), using python requests and BeautifulSoup:
import requests
from bs4 import BeautifulSoup
import json
proxy_dict = {} # set according to system needs
nextId = "bn:00040680n" # the GPS page
r = requests.get('https://babelnet.io/v5/getOutgoingEdges?id='+nextId+'&key=<mykey>', proxies = proxy_dict)
idsoup = BeautifulSoup(r.text, "lxml")
jsonedgesitem = json.loads(idsoup.html.body.p.string)
for relation in jsonedgesitem:
lang = relation.get("language")
if lang == "EN" or lang == "MUL":
if "pointer" in relation:
shortName = relation["pointer"].get("shortName")
if shortName != "related" and shortName != "gloss-related":
print(json.dumps(relation,indent=2))
I'm screening out non-English links, as well as links that are just "related" and "gloss-related" links, which are the vast majority.
That produces the following output:
{
"pointer": {
"name": "operator",
"fSymbol": "wd92",
"relationGroup": "OTHER",
"shortName": "operator",
"isAutomatic": false
},
"language": "MUL",
"target": "bn:00001859n",
"normalizedWeight": 0.0,
"weight": 0.0
}
{
"pointer": {
"name": "use",
"fSymbol": "wd148",
"relationGroup": "OTHER",
"shortName": "use",
"isAutomatic": false
},
"language": "MUL",
"target": "bn:00051760n",
"normalizedWeight": 0.0,
"weight": 0.0
}
{
"pointer": {
"name": "use",
"fSymbol": "wd148",
"relationGroup": "OTHER",
"shortName": "use",
"isAutomatic": false
},
"language": "MUL",
"target": "bn:00062699n",
"normalizedWeight": 0.0,
"weight": 0.0
}
{
"pointer": {
"name": "Hypernym",
"fSymbol": "@",
"relationGroup": "HYPERNYM",
"shortName": "is-a",
"isAutomatic": false
},
"language": "EN",
"target": "bn:00057078n",
"normalizedWeight": 0.0,
"weight": 0.0
}
{
"pointer": {
"name": "has_part",
"fSymbol": "wd76",
"relationGroup": "HOLONYM",
"shortName": "has_part",
"isAutomatic": false
},
"language": "MUL",
"target": "bn:15441159n",
"normalizedWeight": 0.0,
"weight": 0.0
}
{
"pointer": {
"name": "has_part",
"fSymbol": "wd76",
"relationGroup": "HOLONYM",
"shortName": "has_part",
"isAutomatic": false
},
"language": "MUL",
"target": "bn:16971426n",
"normalizedWeight": 0.0,
"weight": 0.0
}
{
"pointer": {
"name": "country_of_origin",
"fSymbol": "wd35",
"relationGroup": "OTHER",
"shortName": "country_of_origin",
"isAutomatic": false
},
"language": "MUL",
"target": "bn:00003341n",
"normalizedWeight": 0.0,
"weight": 0.0
}
{
"pointer": {
"name": "subclass_of",
"fSymbol": "wd21",
"relationGroup": "HYPERNYM",
"shortName": "subclass_of",
"isAutomatic": false
},
"language": "MUL",
"target": "bn:00007477n",
"normalizedWeight": 0.0,
"weight": 0.0
}
{
"pointer": {
"name": "country",
"fSymbol": "wd3",
"relationGroup": "OTHER",
"shortName": "country",
"isAutomatic": false
},
"language": "MUL",
"target": "bn:00003341n",
"normalizedWeight": 0.0,
"weight": 0.0
}
{
"pointer": {
"name": "Hyponym",
"fSymbol": "~@w",
"relationGroup": "HYPONYM",
"shortName": "has-kind",
"isAutomatic": true
},
"language": "EN",
"target": "bn:01177672n",
"normalizedWeight": 0.0,
"weight": 0.0
}
{
"pointer": {
"name": "Hyponym",
"fSymbol": "~@w",
"relationGroup": "HYPONYM",
"shortName": "has-kind",
"isAutomatic": true
},
"language": "EN",
"target": "bn:02122452n",
"normalizedWeight": 0.0,
"weight": 0.0
}
{
"pointer": {
"name": "Hyponym",
"fSymbol": "~@w",
"relationGroup": "HYPONYM",
"shortName": "has-kind",
"isAutomatic": true
},
"language": "EN",
"target": "bn:03088008n",
"normalizedWeight": 0.0,
"weight": 0.0
}
{
"pointer": {
"name": "Hypernym",
"fSymbol": "@wd",
"relationGroup": "HYPERNYM",
"shortName": "is-a",
"isAutomatic": false
},
"language": "MUL",
"target": "bn:00732900n",
"normalizedWeight": 0.0,
"weight": 0.0
}
{
"pointer": {
"name": "Hypernym",
"fSymbol": "@w",
"relationGroup": "HYPERNYM",
"shortName": "is-a",
"isAutomatic": true
},
"language": "EN",
"target": "bn:00732900n",
"normalizedWeight": 0.0,
"weight": 0.0
}
Where it is documented what kinds of relations can be included here? In particular, is there a meaningful difference between the Hypernym "is-a" and Hypernym "subclass-of" types of relation? Where are the fSymbol values documented?