How to find Synset name from a json input file in Wordnet python

192 Views Asked by At

I am trying to get the Synset name for each word in a dictionary.json file. I have tried the following:

import nltk
import json
from nltk.corpus import wordnet as wn

f = open('dictionary_raw.json',)

data = json.load(f)

for i in data:
    syn = wn.synsets(i.split())[0]
    print("Synset name: ", syn.name())
f.close()

When I run this I get the following error:

AttributeError: 'list' object has no attribute 'lower'

This is an example of what the input looks like:

['Hello']
['Mighty']
['BONUS', 'Local', 'Soccer']
[]
['45', 'Finance', 'Street']
0

There are 0 best solutions below