This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
If we compare through java then these two above Strings are different but when we see normally then it appears to be same.
Can we do such things in java which check the String intelligently.Means if we companre above two Strings then it give result as MATCHED inspite on Not Matched
That is very difficult, because what exactly means "appears to be the same"? They appear to be the same when a human quickly looks at both strings?
In order to write a program you must be able to exactly specify what this means, which is very difficult. "Appears to be the same" is a very fuzzy and inexact definition. Note that it might also be different for different people - maybe for you those two strings appear to be the same if you look at them quickly, but if I look at them quickly then I see immediately that they are different.
One idea would be to use some kind of diff algorithm and count the number of differences.
It's hard to give more advice without knowing what you want to do this for.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
ram gaurav
Ranch Hand
Joined: Mar 29, 2006
Posts: 208
posted
0
Thanks for replies.
Like i have two Strings :
String 1: My name is abc
String 2: My name abc
These above two Strings are different but i want that when this type of copmparision will come it will show result as equal inspite of not equal
Ok, we understood that, you're just repeating your question.
Can you please explain exactly when you want the comparison to return "equal" and when it is "not equal"? I mean exactly, without fuzzy descriptions like "when they look almost the same".
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
Or at least start by showing more examples.
For example, what about
My name is
My abc
My name is cba
My name is Ulf
My name is Ilja
Your name is abc
Name is abc
My is abc
Which of those should "be equal to" String 1?
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35237
7
posted
0
You might be talking about the concept of using a stopword filter for text. The idea is to filter out common words like "the", "and" and "is" before comparing text, because they don't contribute to the meaning of the text.
A related important concept is stemming, which reduces words like "fishing", "fished", "fish", and "fisher" to their root, "fish".
There is no such method which compares strings so intelligently as you want.So,you have to make your own method and use that method wherever you want. I think your requirement is only for small sentences like : String1 = My name is abc String2 = My name abc You can go towards grammer side also like.. Adjective+noun+adverb+noun,so that wherever you get this sequence you can replace it with Adjective+noun+noun. I don't know to which level you want,means can the sentences be big also... I have told you option ,rest you can try and decide yourself
Well Tony, you wouldn't even have to think very hard to implement it in Java, because you can just copy and paste the source code from the website you linked to!
Tony Morris
Ranch Hand
Joined: Sep 24, 2003
Posts: 1608
posted
0
Originally posted by Jesper Young: Well Tony, you wouldn't even have to think very hard to implement it in Java, because you can just copy and paste the source code from the website you linked to!
Nice one I have written in Java before (using destructive update on an array), but I also have it written in Scala (which is callable from Java) using pure function calls (the Scala compiler tail call eliminates). I have also written it in C# and Haskell. LCS-based delta (and therefore, ED) is a problem that I happen to be very familiar with