Does anybody have an idea how to compare two strings?
What I want to know is the percentage of the differences between the strings
Thx,
Dennieku 5 3395
Dennieku <de******@hotma il.com> wrote: Does anybody have an idea how to compare two strings? What I want to know is the percentage of the differences between the strings
Could you define exactly what you mean by "percentage of the
differences"? If you can define it *exactly*, that will probably
suggest a way of calculating it simply.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
I think what you're looking for (basically) is the Levenshtein edit-distance
algorithm. This algorithm takes two strings as an input. It then counts
the number of corrections (insertions, deletions or substitution of
individual characters) that are necessary to make the strings the same.
For example, with the inputs "Hello World" and "Hllo Woorld," it will return
"2" since there are two corrections necessary: insert an "e" in the first
word, and delete an "o" in the second word.
This isn't built into the .Net framework, so you'll have to build your own.
Try a Google search on "edit distance algorithm." There's an explanation of
the algorithm here, with some VB6 code: http://www.merriampark.com/ld.htm
"Dennieku" <de******@hotma il.com> wrote in message
news:K3******** *************@a msnews02.chello .com... Does anybody have an idea how to compare two strings? What I want to know is the percentage of the differences between the
strings Thx, Dennieku
"Jon Skeet" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@news.microsof t.com... Dennieku <de******@hotma il.com> wrote: Does anybody have an idea how to compare two strings? What I want to know is the percentage of the differences between the strings
Could you define exactly what you mean by "percentage of the differences"? If you can define it *exactly*, that will probably suggest a way of calculating it simply.
I think he means something like DIFFERENCE or
SOUNDEX in SQL Server.
Unfortunately there's nothing like this built into
..NET and it's not a simple algorithm, but I'm sure
you could probably find some examples on some
academic pages. I think it has something to do
with phonetic analysis of the words and then
comparing the likeness of the placement of the
various phonetic parts relative to the other
string. MSR might have something like this
already, they are always suprising me with
new projects.
-c
Robert Jacobson <rj************ **********@nosp am.com> wrote: I just noticed your cross-post to .dotnet.languag es.csharp -- the VB example probably isn't what you're looking for. <g> That link also has examples in Java and C++ that would be easy to translate to C#.
In particular, I'd be more than happy to translate it from Java to C#,
if this is indeed the algorithm required.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
I did a search .. you might find something useful in here... http://dotnet.jku.at/applications/Diff/Src.aspx
Jon
"Chad Myers" <cm****@N0.SP.A M.austin.rr.com > wrote in message
news:ut******** *****@TK2MSFTNG P10.phx.gbl... "Jon Skeet" <sk***@pobox.co m> wrote in message news:MP******** *************** *@news.microsof t.com... Dennieku <de******@hotma il.com> wrote: Does anybody have an idea how to compare two strings? What I want to know is the percentage of the differences between the strings
Could you define exactly what you mean by "percentage of the differences"? If you can define it *exactly*, that will probably suggest a way of calculating it simply.
I think he means something like DIFFERENCE or SOUNDEX in SQL Server.
Unfortunately there's nothing like this built into .NET and it's not a simple algorithm, but I'm sure you could probably find some examples on some academic pages. I think it has something to do with phonetic analysis of the words and then comparing the likeness of the placement of the various phonetic parts relative to the other string. MSR might have something like this already, they are always suprising me with new projects.
-c
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: beliavsky |
last post by:
By mistake I coded something like
print ("1" > 1)
and got the result "True". Comparing an integer and a string seems
meaningless to me, and I would prefer to have an exception thrown. Can
someone explain why Python allows comparisons between integers and
strings, and how it handles those cases? Why is "1" > 1?
Pychecker does not warn about the line of code above -- I wish it did.
|
by: William Park |
last post by:
How do you compare 2 strings, and determine how much they are "close" to
each other? Eg.
aqwerty
qwertyb
are similar to each other, except for first/last char. But, how do I
quantify that?
I guess you can say for the above 2 strings that
- at max, 6 chars out of 7 are same sequence --> 85% max
|
by: Curtis Gilchrist |
last post by:
I am required to read in records from a file and store them in descending
order by an customer number, which is a c-style string of length 5. I am
storing these records in a linked list. My problem is in comparing the
customer number I just read in with those in the list. I'm not sure how to
go about comparing c-style strings for greater than, less than.. here is how
I am currently trying to do it:
while( ( custinfo.number >...
|
by: agent349 |
last post by:
First off, I know arrays can't be compared directly (ie: if (arrary1
== array2)). However, I've been trying to compare two arrays using
pointers with no success. Basically, I want to take three sets of
character strings from the user. Then I want to run through each
element and compare the two strings. If they match I print they
match... I'm having a bit of trouble with the actual loop through each
array using the pointers and comparing...
|
by: BrianJones |
last post by:
I have a problem with the int strcmp(str1,str2) function:
When I do:
char *pass;
char *passv;
pass = getpass("Please enter.....");
passv = getpass("Please verify.....");
| |
by: William Krick |
last post by:
I'm currently evaluating two implementations of a case insensitive
string comparison function to replace the non-ANSI stricmp(). Both of
the implementations below seem to work fine but I'm wondering if one is
better than the other or if there is some sort of hybrid of the two
that would be superior.
IMPLEMENTATION 1:
#ifndef HAVE_STRCASECMP
|
by: Manny Chohan |
last post by:
Hi, i have two datetime values in format 11/22/04 9:00 AM and 11/22/04 9:30
AM. How can i compare dates .net c# or if there is any other way such as
Javascript.
Thanks
Manny
|
by: luc.saffre |
last post by:
Hello,
here is something that surprises me.
#coding: iso-8859-1
s1=u"Frau Müller machte große Augen"
s2="Frau Müller machte große Augen"
if s1 == s2:
pass
|
by: Jetboy555 |
last post by:
Sample input:
2000 Georgia Tech 30 Virginia 20
1999 Virginia 20 Virginia tech
My Problem is in taking the input in correctly. I take the year in correctly, but i'm having trouble with the names because some of them are two strings long.
right now i have
input << year << Winner1 << Winner2 < Score << Loser1 < Loser2 << Score
|
by: Pugi! |
last post by:
hi,
I am using this code for checking wether a value (form input) is an
integer and wether it is smaller than a given maximum and greater then
a given minimum value:
function checkInteger(&$value, $checks) {
$err = '';
if (!is_numeric($value) || (floatval($value) != intval($value))) {
$err .= 'Input must be an integer. ';
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |