Package: pyglottolog
pyglottologProgrammatic access toGlottolog data.InstallTo installpyglottologyou need a python installation on your system, running python >3.7. RunpipinstallpyglottologThis will also install the command line interfaceglottolog.Note:To make use ofpyglottologyou also need a local copy of theGlottolog data. This can bea clone of theglottolog/glottologrepository or your fork of it,an unzippedreleased version of Glottologfrom GitHub,or an unzipped download of areleased version of Glottologfrom ZENODO.Make sure you remember where this local copy of the data is located - you may
have to pass this location as option when usingpyglottolog.A convenient way to clone the data repository, keep it updated and access it
frompyglottologis provided
bycldfbench. See theREADMEfor details.Python APIUsingpyglottolog, Glottolog data can be accessed programmatically from within python programs.
All functionality is mediated through an instance ofpyglottolog.Glottolog, e.g.>>>frompyglottologimportGlottolog>>>glottolog=Glottolog('.')>>>print(glottolog)<Glottologreposv0.2-259-g27ac0efat/.../glottolog>For details, refer to theAPI documentation at readthedocs.Command line interfaceCommand line functionality is implemented via sub-commands ofglottolog. The list of
available sub-commands can be inspected running$glottolog-h
usage:glottolog[-h][--log-levelLOG_LEVEL][--reposREPOS][--repos-versionREPOS_VERSION]COMMAND...

optionalarguments:-h,--helpshowthishelpmessageandexit--log-levelLOG_LEVELloglevel[ERROR|WARN|INFO|DEBUG](default:20)--reposREPOScloneofglottolog/glottolog--repos-versionREPOS_VERSIONversionofrepositorydata.Requiresagitclone!(default:None)availablecommands:Run"COMAMND -h"togethelpforaspecificcommand.COMMANDcldfDumpGlottologdataasCLDFdatasetcreateCreateanewlanguoiddirectoryforalanguoidspecifiedbynameandlevel.editOpenalanguoid'sINIfileinatexteditor.htmlmapCreateanHTML/Javascriptmap(usingleaflet)ofGlottologlanguoids.iso2codesMapISOcodestothelistofallGlottologlanguagesanddialectssubsumed"under"it.langdatastatsListallmetadatafieldsusedinlanguoidINIfilesandtheirfrequency.langsearchSearchGlottologlanguoids.languoidsWritelanguoidsdatatocsvfilesrefsearchSearchGlottologreferencessearchindexIndexshowDisplaydetailsofaGlottologobject.treePrinttheclassificationtreestartingataspecificlanguoid.Extracting languoid dataGlottolog data is often integrated with other data or incorporated as reference
data in tools, e.g. asLanguageTablein aCLDFdataset.To do this, the LanguageTable fromglottolog/glottolog-cldfcould be copied, or one may useglottolog'slanguoidssubcommand, which
dumps basic languoid data into a CSVW file with accompanying metadata:glottologlanguoids[--output=OUTDIR][--version=VERSION]This will create a CSVW package, i.e.a CSV tableglottolog-languoids-VERSION.csvand a JSON descriptionglottolog-languoids-VERSION.csv-metadata.jsonwhereVERSIONis the result of runninggit describeon the data repository,
or the version string passed as--version=VERSIONin case you are running the command
on an export of the repository or a download from ZENODO.Languoid searchTo allow convenient search across all languoid info files,pyglottologcomes with functionality
to create and search aWhooshindex. To do
so, runglottologsearchindexThis will take a couple of minutes (~15 on a somewhat beefy laptop with SSD) and build an index of
about 800 MB size atbuild/.Now you can search the index, e.g. using alternative names as query:$glottologlangsearch"Abipónok"1matches
Abipon[abip1241]language
languoids/tree/guai1249/guai1250/abip1241/md.ini
Abipónok[hu]1matchesBut you can also exploit the schema defined inpyglottolog.fts.get_langs_index;
i.e. use fields inyour query:$glottologlangsearch"country:PG"...

Alamblak[alam1246]language
languoids/tree/sepi1257/sepi1258/east2496/alam1246/md.ini
PapuaNewGuinea(PG)906matches

$glottolog--repos=.langsearch"iso:mal"...

Malayalam[mala1464]language
languoids/tree/drav1251/sout3133/sout3138/tami1291/tami1292/tami1293/tami1294/tami1297/tami1298/mala1541/mala1464/md.ini1matchesReference searchThe same can be done for reference data: To create a Whoosh index with all reference data, runglottologsearchindexNow you can query the index (using the fields described inthe schema):$glottologrefsearch"author:Haspelmath AND title:Atlas"...(13matches)