LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-01-2021, 03:01 PM   #16
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,037

Rep: Reputation: Disabled

@danielbmartin. Well, fstrcmp thinks your example strings are pretty similar:
Code:
$ fstrcmp 'Four score and seven years ago' Four_score_and_seven_years_ago
0.8333
It scores pairs of strings on the scale from 0.0 (utterly different) to 1.0 (identical). OTOH, it will score most other suggested pairs at over 70% as well.
Code:
$ fstrcmp 'Yes i know it for sure' 'Yes i know is for real'
0.8636
$ fstrcmp 'yes i know it for sure' 'no i know it for not'
0.7143
$ fstrcmp 'Yes i know it for sure' 'Yet I know it was real'
0.6818
$ fstrcmp 'Yes i know it for sure' 'Yes i saw it for sure'
0.8837
 
2 members found this post helpful.
Old 11-01-2021, 04:08 PM   #17
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,777
Blog Entries: 23

Rep: Reputation: 3785Reputation: 3785Reputation: 3785Reputation: 3785Reputation: 3785Reputation: 3785Reputation: 3785Reputation: 3785Reputation: 3785Reputation: 3785Reputation: 3785
Quote:
Originally Posted by shruggy View Post
@danielbmartin. Well, fstrcmp thinks your example strings are pretty similar:
Code:
$ fstrcmp 'Four score and seven years ago' Four_score_and_seven_years_ago
0.8333
It scores pairs of strings on the scale from 0.0 (utterly different) to 1.0 (identical). OTOH, it will score most other suggested pairs at over 70% as well.
The OP still has not given us a definition of what they mean by similar, and and conversely for dissimilar. They have provided a few examples of similar (none for dissimilar as far as I recall, i.e. sets no lower bound) which is not a really useful definition of their use case.

If they are looking for things that would sound similar when spoken then the options offered so far may be appropriate.

But if they are looking for similar meaning, such as for automatically scoring answers on a test, this would be bad news:

Quote:
Originally Posted by shruggy View Post
Code:
fstrcmp 'Yes i know it for sure' 'Yet I know it was real'
0.6818
fstrcmp 'yes i know it for sure' 'no i know it for not'
0.7143
So it would still be very helpful if we had some idea of the intended use case, if not an explicit definition of similar and dissimilar.

Last edited by astrogeek; 11-01-2021 at 04:11 PM.
 
1 members found this post helpful.
Old 11-02-2021, 09:49 AM   #18
pedropt
Member
 
Registered: Aug 2014
Distribution: Devuan
Posts: 324

Original Poster
Rep: Reputation: Disabled
Thanks for the tips guys , that will do the trick .
 
Old 11-02-2021, 03:00 PM   #19
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 10,188

Rep: Reputation: 4752Reputation: 4752Reputation: 4752Reputation: 4752Reputation: 4752Reputation: 4752Reputation: 4752Reputation: 4752Reputation: 4752Reputation: 4752Reputation: 4752
Fuzzy finding libraries on NPM typically use this algorithm:

https://en.wikipedia.org/wiki/Levenshtein_distance
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Another root hole in OS X. We know it, you know it, the bad people know it, and no patch exis LXer Syndicated Linux News 0 08-18-2015 09:42 PM
LXer: Another root hole in OS X. We know it, you know it, the bad people know it – and no patch ex LXer Syndicated Linux News 0 08-18-2015 09:12 PM
AWK a variable Ouptut to a new variable and using the new variable with the old one alertroshannow Linux - Newbie 4 02-16-2009 01:08 AM
using a variable in another variable. dina3e Programming 3 07-18-2008 12:17 AM
Shell scripting : how to name a variable with the value of another variable JimOrJoe Programming 9 06-15-2008 10:36 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration