Jovian
⭐️
Sign In
In [2]:
import jovian

In [2]:
import pandas as pd
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 

#ACTUAL CODE WITHOUT CUSTOM DICTIONARY

In [4]:
%%time
import enchant,difflib
import string

d = enchant.Dict("en_US") 
  
# Taking input from user 
sentance = input("Enter word: ") 
for c in string.punctuation:
     sentance = sentance.replace(c,"")

listofsentances = sentance.split()
actual_message = []
for i in listofsentances:
        dict,max = {},0
        a = set(d.suggest(i))
        for b in a:
            tmp = difflib.SequenceMatcher(None, word, b).ratio();
            dict[tmp] = b
            if tmp > max:
                max = tmp
        print(dict)
        if any(dict.keys()) > 0.2:
            actual_message.append(dict[max])
        else:
            actual_message.append(i)
message = " ".join(actual_message)            

Enter word: CPU times: user 65.7 ms, sys: 8.32 ms, total: 74 ms Wall time: 576 ms
In [5]:
actual_message

Out[5]:
[]
In [6]:
message = " ".join(actual_message)
In [7]:
message
Out[7]:
''
In [8]:
dict.keys()
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-8-9b6e82ae06ce> in <module> ----> 1 dict.keys() TypeError: descriptor 'keys' of 'dict' object needs an argument
In [9]:
s = "arbaz     khan sa   lem"
In [10]:
len(s.split())
Out[10]:
4
In [11]:
s = "string. With. Punctuation?" # Sample string
import string
for c in string.punctuation:
     s= s.replace(c,"")
In [12]:
s
Out[12]:
'string With Punctuation'
In [ ]:
jovian.commit()
[jovian] Saving notebook..
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]: