'''{
    "wordId": "1",
    "word": "रेडियो",
    "type": "noun"
}'''
import openpyxl,json
wb=openpyxl.open("POS Sentence.xlsx",data_only=True)
sheet=wb.worksheets[0]
def create():   
    node=[]
    qid=1
    for i in range(2,sheet.max_row+1):
        obj={}
        if sheet.cell(row=i,column=1).value!= None:
            obj["sentenceId"]=qid
            obj["question"]=sheet.cell(row=i,column=1).value.strip()
            word_list=[]
            for j in range(2,5):
                if sheet.cell(row=i,column=j).value!=None:
                    word_list.append(
                        {
                            "words":sheet.cell(row=i,column=j).value.strip() ,
                            "type":sheet.cell(row=1,column=j).value.strip()
                        }
                    )
            obj["classification"]=word_list
            node.append(obj)
        # print(sheet.cell(row=i,column=5).value)
        qid+=1
    with open("Data.json", 'w', encoding='utf-8') as outfile:   
            json.dump(node, outfile, indent=4, ensure_ascii=False)
create()