Detect similar sounding words in Ruby
By : Matteo
Date : March 29 2020, 07:55 AM
it helps some times I think you're describing levenshtein distance. And yes, there are gems for that. If you're into pure Ruby go for the text gem. code :
$ gem install text
Text::Levenshtein.distance('test', 'test') # => 0
Text::Levenshtein.distance('test', 'tent') # => 1
$ gem install levenshtein
String.module_eval do
def similar?(other, threshold=2)
distance = Text::Levenshtein.distance(self, other)
distance <= threshold
end
end
|
Detect similar sounding words in java
By : svirpav
Date : March 29 2020, 07:55 AM
|
Fetching similar sounding names from a table
By : Janak
Date : March 29 2020, 07:55 AM
To fix the issue you can do You could use MySQL SOUNDEX: code :
SELECT * FROM `stu_table` WHERE STRCMP(SOUNDEX(`stu_name`), SOUNDEX('Mrinmoy')) <= 0
|
How to get the similar-sounding words together
By : user2573844
Date : March 29 2020, 07:55 AM
will help you First, you need to use a right way to get the similar sounding words i.e. string similarity, I would suggest: Using jellyfish: code :
from jellyfish import soundex
print(soundex("two"))
print(soundex("to"))
T000
T000
def getSoundexList(dList):
res = [soundex(x) for x in dList] # iterate over each elem in the dataList
# print(res) # ['T000', 'F630', 'F630', 'D263', 'T000', 'D263']
return res
dataList = ['two','fourth','forth','dessert','to','desert']
print([x for x in sorted(getSoundexList(dataList))])
['D263', 'D263', 'F630', 'F630', 'T000', 'T000']
import fuzzy
soundex = fuzzy.Soundex(4)
print(soundex("to"))
print(soundex("two"))
T000
T000
from itertools import groupby
def getSoundexList(dList):
return sorted([soundex(x) for x in dList])
dataList = ['two','fourth','forth','dessert','to','desert']
print([list(g) for _, g in groupby(getSoundexList(dataList), lambda x: x)])
[['D263', 'D263'], ['F630', 'F630'], ['T000', 'T000']]
from operator import itemgetter
def getSoundexDict(dList):
return sorted(dict_.items(), key=itemgetter(1)) # sorting the dict_ on val
dataList = ['two','fourth','forth','dessert','to','desert']
res = [soundex(x) for x in dataList] # to get the val for each elem
dict_ = dict(list(zip(dataList, res))) # dict_ with k,v as name/val
print([list(g) for _, g in groupby(getSoundexDict(dataList), lambda x: x[1])])
[[('dessert', 'D263'), ('desert', 'D263')], [('fourth', 'F630'), ('forth', 'F630')], [('two', 'T000'), ('to', 'T000')]]
|
Calculate number and names of similar sounding words from two different data frames
By : sanjeev K
Date : October 04 2020, 10:00 PM
I wish this helpful for you I have two data frames , An option is agrep. Based on the description off agrep code :
cbind(df1['Word1'], do.call(rbind, lapply(df1$Word1, function(x) {
i1 <- agrep(x, df2$Word2)
data.frame(links = toString(df2$Word2[i1]) , counts = length(i1))})))
|