domain2synsets = defaultdict(list)
synset2domains = defaultdict(list)
for i in open('wn-domains-3.2-20070223', 'r'):
    ssid, doms = i.strip().split('\t')
doms = doms.split()
synset2domains[ssid] = doms
for d in doms:
    domain2synsets[d].append(ssid)
for ss in wn.all_synsets():
    ssid = str(ss.offset).zfill(8) + '-' + ss.pos()
if synset2domains[ssid]:
    print(ss, ssid, synset2domains[ssid])
for dom in sorted(domain2synsets):
    pass
How to get domain of words using WordNet in Python?