Skip to content

Instantly share code, notes, and snippets.

@LinguList
Last active July 16, 2018 15:08
Show Gist options
  • Save LinguList/7804cb127e74a9263b4eab9c5af4bc6f to your computer and use it in GitHub Desktop.
Save LinguList/7804cb127e74a9263b4eab9c5af4bc6f to your computer and use it in GitHub Desktop.
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