Skip to content

Instantly share code, notes, and snippets.

@LinguList

LinguList/README.md

Last active Jul 16, 2018
Embed
What would you like to do?
Exporting Sublists form a Wordlist with LingPy and Concepticon

Exporting Sublists form a Wordlist with LingPy and Concepticon

This gist describes, how you can extract sublists from a wordlist in LingPy with help of the pyconcepticon API. See https://calc.hypotheses.org/date/2018/07 for details on the code and additional explanations.

from lingpy import *
from pyconcepticon.api import Concepticon
concepts = {
c.concepticon_id: c.english for c in Concepticon(
).conceptlists['Kolipakam-2018-100'].concepts.values()
}
jachontov = [
c.concepticon_id for c in Concepticon(
).conceptlists['Yakhontov-1991-35'].concepts.values()
]
# get the sublist for jachontov shared with the given dataset
sublist = [b for a, b in concepts.items() if a in jachontov]
# load the wordlist
wl = Wordlist('DravLex.tsv')
# output data
wl.output(
'tsv',
filename='DravLex-sublist',
subset=True,
rows=dict(concept = ' in '+str(sublist))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment