Question

I have an entire list of words with the correct spellings called ref.txt . i have a list of sentences and i have managed to extract words from them using regex. i'll elaborate it with an example .
suppose ref.txt contains - Mumbai , Andheri ,Jacob Circle, Bandra . I have a list of sentences like -

['Blue Meadows near andhri ', 'Oberoi Heights opp windy road off Bnadra' , 
'Red Heavens club ,behind Mumbia club near Jacob Circle']  

there isnt much documentation about jellyfish.

import jellyfish as jf  
jf.jaro_distance(andhri,andheri)

the problem is , after extraction of the words using regex,how do i compare it with the entire list.. my algorithm should automatically suggest 'andheri' for andhri due to lowest cost..
in case u have some other ideas to implement , plz do reccommend.. thanks

Was it helpful?

Solution

Right so by what I've understood, you want your program to suggest the word closest to what is entered by the user. There's no simple method to do this. You'll have to go with character by character comparison. Compare each character in "andhri" with the character of every word in your list. And keep a counter. Preferably, a list of counters would work better for you. Compare each letter in each word in your list with the letters in "andhri" and everytime you get a match, increment that respective counter. Once you are done comparing each character of each word on your list with "andhri", check the counters. The word corresponding to the highest counter should be suggested to the user.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top