loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.15536960870688032","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"aW1wb3J0IHBhbmRhcyBhcyBwZAojbG9hZCBmaWxlCnF1cmFuID0gcGQucmVhZF9jc3YoJ3F1cmFuLXNpbXBsZS1jbGVhbi50eHQnLCBzZXA9InwiLCBoZWFkZXI9Tm9uZSkKI2Ryb3AgZW5kIG9mIGZpbGUgaW5mb3JtYXRpb24KcXVyYW4uZHJvcChxdXJhbi5pbmRleFs2MjM2Ol0sIGlucGxhY2U9VHJ1ZSkKI3JlbmFtZSBjb2x1bW5zCnF1cmFuLmNvbHVtbnMgPSBbJ3N1cmFfbm8nLCAnYXlhX25vJywgJ3RleHQnXQojY2hhbmdlIGR0eXBlcyBvZiBzb21lIGNvbHVtbnMgdG8gaW50ZWdlcgpxdXJhblsnc3VyYV9ubyddID0gcGQudG9fbnVtZXJpYyhxdXJhblsnc3VyYV9ubyddLCBkb3duY2FzdCA9ICdpbnRlZ2VyJykKcXVyYW5bJ2F5YV9ubyddID0gcGQudG9fbnVtZXJpYyhxdXJhblsnYXlhX25vJ10sIGRvd25jYXN0ID0gJ2ludGVnZXInKQoKI3RoaXMgZnVuY3Rpb24gZmluZCB1bmlxdWUgd29yZHMsIAojIHRoZSAnbmVnJyBwYXJhbWV0ZXJzIGZpbmQgdGhlIHdvcmRzIG5vdCBpbiB0aGlzIHN1cmEKZGVmIHVuaXF1ZV93b3JkcyhzdXJhLCBuZWc9MCk6CiAgICBpZiBuZWc9PTA6CiAgICAgICAgc2VsZWN0aW9uID0gcXVyYW5bcXVyYW5bJ3N1cmFfbm8nXT09c3VyYV0udGV4dC5zdHIuc3BsaXQoKS50b2xpc3QoKQogICAgZWxzZToKICAgICAgICBzZWxlY3Rpb24gPSBxdXJhbltxdXJhblsnc3VyYV9ubyddIT1zdXJhXS50ZXh0LnN0ci5zcGxpdCgpLnRvbGlzdCgpCiAgICBmbGF0X2xpc3QgPSBbaXRlbSBmb3IgYXlhIGluIHNlbGVjdGlvbiBmb3IgaXRlbSBpbiBheWFdCiAgICByZXR1cm4gc2V0KGZsYXRfbGlzdCkKCiN0aGlzIGZ1bmN0aW9uIHVzZXMgdGhlIGFib3ZlIG9uZSB0byBmaW5kIHdvcmRzIG9ubHkgdXNlZCBpbiB0aGlzIHN1cmFoCmRlZiB1bmlxdWUoc3VyYSk6CiAgICByZXR1cm4gKHNvcnRlZChsaXN0KHNldCh1bmlxdWVfd29yZHMoc3VyYSkpLXNldCh1bmlxdWVfd29yZHMoc3VyYSwxKSkpKSkKCnMgPSBpbnB1dCgiRW50ZXIgU3VyYSBOby46ICIpCm91dCA9IHVuaXF1ZShpbnQocykpCm91dCA9ICcsJy5qb2luKG91dCkKcHJpbnQob3V0KQo="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import pandas as pd
#load file
quran = pd.read_csv('quran-simple-clean.txt', sep="|", header=None)
#drop end of file information
quran.drop(quran.index[6236:], inplace=True)
#rename columns
quran.columns = ['sura_no', 'aya_no', 'text']
#change dtypes of some columns to integer
quran['sura_no'] = pd.to_numeric(quran['sura_no'], downcast = 'integer')
quran['aya_no'] = pd.to_numeric(quran['aya_no'], downcast = 'integer')

#this function find unique words, 
# the 'neg' parameters find the words not in this sura
def unique_words(sura, neg=0):
    if neg==0:
        selection = quran[quran['sura_no']==sura].text.str.split().tolist()
    else:
        selection = quran[quran['sura_no']!=sura].text.str.split().tolist()
    flat_list = [item for aya in selection for item in aya]
    return set(flat_list)

#this function uses the above one to find words only used in this surah
def unique(sura):
    return (sorted(list(set(unique_words(sura))-set(unique_words(sura,1)))))

s = input("Enter Sura No.: ")
out = unique(int(s))
out = ','.join(out)
print(out)