A python 3 interface for BabelNet https://babelnet.org/ This is the extension of HTTP API https://babelnet.org/guide
Please also check the official python package https://pypi.org/project/babelnet/ because your purpose are probably resolved. This repository is unofficial when official package was not existed or didn't work completely. I don't know the official package covers all methods in this repository, but, it seems good :)
Please download the project, use cd to move to the babelnetpy folder and run:
python setup.py install
Please register BabelNet (https://babelnet.org/register) and get your API key. Example codes is in examples directory.
from babelnetpy.babelnet import BabelNet
bn = BabelNet("your API key") # or BabelNet(open("key.txt", "r").read())
synsets = bn.getSynsets("bn:03083790n")
print(synsets[0].senses)
#getSenses is able to use after only getSynsets
senses = bn.getSenses("BabelNet", "EN")
print(senses[0])
#getSynsetIdsFromResourceID is able to use after only getSynsets
synset_ids = bn.getSynsetIdsFromResourceID("BabelNet", "EN", "NOUN", "WIKI")
print(synset_ids[0])
The purpose of "key.txt" used in BabelNet(open("key.txt", "r").read())
is to avoid a mistake that you update your API key accidentaly.
If you don't use the github or another web application, I recommend to use BabelNet("your API key")
because you don't need to make an additional file.
The "key.txt" in the example code means that you need to make "key.txt" and write your API key in that file. The API key is written on the home page after log-in.
In Apr/2021, BabelNet updates to version 6; however, this program does not change because I don't debug it. If you want to use the new version, you write 'bn.API_PATH = "https://babelnet.io/v6/"' after 'bn = BabelNet("your API key")'. (If anyone debug it and this program works correctly, please tell me (send the comment to issue 6) / pull requests.) Of course, self.API_PATH in line 15 of babelnet.py is same.
You need to set https://github.com/jackee777/babelnet_offline and run this server.
from babelnetpy.babelnet import BabelNet
bn = BabelNet(None)
bn.API_PATH = "http://localhost:1000/"
As far as I know, this server works well. However, I'm not familiar with the programming of the server. If you have trouble with the server, "babelnetlookup" is good and I sometimes maintenance it (unfortunately, babelnetpy cannot use against babelnetlookup).
HTTP API has more functions than this code has; however, it is needed to access several times. To reduce times and avoid using babelcoins, I don't make their functions. Perhaps, their functions may help us to search Babelnet, but I don't know whether I add them or not.
EN,
ES,
IT,
CA,DE,FR,IS,PL,RO,AF,AR,BG,CS,CY,DA,EL,ET,FA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BABELNET, // BabelNet senses, not available as of version 3.0
WN, // WordNet senses
OMWN, // Open Multilingual WordNet (deprecate)
IWN, // Italian 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
MCR_EU, // Open Multilingual WordNet (Basque)
OMWN_HR, // Open Multilingual WordNet (Croatian)
SLOWNET, // Open Multilingual WordNet (Slovenian)
OMWN_ID, // Open Multilingual WordNet (Indonesian)
OMWN_IT, // Open Multilingual WordNet (Italian)
MCR_GL, // Open Multilingual WordNet (Galician)
ICEWN, // Open Multilingual WordNet (Icelandic)
OMWN_ZH, // Open Multilingual WordNet (Chinese)
OMWN_NO, // Open Multilingual WordNet (Norwegian (Bokm�l))
OMWN_NN, // Open Multilingual WordNet (Norwegian (Nynorsk))
SALDO, // Open Multilingual WordNet (Swedish)
OMWN_JA, // Open Multilingual WordNet (Japanese)
MCR_CA, // Open Multilingual WordNet (Catalan)
OMWN_PT, // Open Multilingual WordNet (Portuguese)
OMWN_FI, // Open Multilingual WordNet (Finnish)
OMWN_PL, // Open Multilingual WordNet (Polish)
OMWN_TH, // Open Multilingual WordNet (Thai)
OMWN_SK, // Open Multilingual WordNet (Slovak)
OMWN_LT, // Open Multilingual WordNet (Lithuanian)
OMWN_NL, // Open Multilingual WordNet (Dutch)
OMWN_AR, // Open Multilingual WordNet (Arabic)
OMWN_FA, // Open Multilingual WordNet (Persian)
OMWN_EL, // Open Multilingual WordNet (Greek)
MCR_ES, // Open Multilingual WordNet (Spanish)
OMWN_RO, // Open Multilingual WordNet (Romanian)
OMWN_SQ, // Open Multilingual WordNet (Albanian)
OMWN_DA, // Open Multilingual WordNet (Danish)
OMWN_FR, // Open Multilingual WordNet (French)
OMWN_MS, // Open Multilingual WordNet (Malay)
OMWN_BG, // Open Multilingual WordNet (Bulgarian)
OMWN_HE, // Open Multilingual WordNet (Hebrew)
OMWN_KO, // Korean WordNet
MCR_PT, // Open Multilingual WordNet (Portuguese)
OMWN_GAE, // Irish WordNet (GAWN)
WORD_ATLAS // WordAtlas
If this program is helpful for you, I want you to give the star this program for me because it leads to assist looking for my job. Have a nice day.