How can I check the input if it's nearly same or not? [duplicate] - c#

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Are there any Fuzzy Search or String Similarity Functions libraries written for C#?
I need to check the similarity of input value -which one user entered- to our records.
12345 vs 1234
12345 vs 13245
Robert vs Robret
etc...
In short; I need to calculate the similarity and tolerate the input in some ratio...

The Levenshtein distance is a string similarity algorithm you could use.

Google shows me this

I think you might be looking for an Edit Distance algorithm.

Related

Convert Numerical Digits in Vocabulary Forms [duplicate]

This question already has answers here:
How can I convert an integer into its verbal representation?
(16 answers)
Closed 7 years ago.
How can I convert final amount of billing to it's related vocabulary form?
I am trying to develop a function which convert it in vocabulary form.
For, ex. 12345 Rs. then it's output should be like this
TWELVE THOUSAND THREE HUNDRED N FORTY FIVE ONLY
is it possible with few easy steps in C# ?
If you are willing to use an external library, i'd suggest you try out Humanizer
Really simply to use and your example would be as simple as.
12345.ToWords(); //it adds extension methods that achieve this.

mobile number length based on the country name selected in the dropdown [duplicate]

This question already has answers here:
RegEx for valid international mobile phone number [duplicate]
(6 answers)
Closed 9 years ago.
In my asp.net application, I have to use the validation for mobile number length based on the country name selected in the dropdown.
I have googled for the solution, but couldn't able to find exact one.
Can anybody share the usefull link or info to me?
Short answer:
You can't (unless you're limited to a very specific subset of countries).
Long answer:
Telephone systems are too varied and - in short - non-standardized to create one "catch all" solution.
While some countries, like the US, got fixed length numbers, others, e.g. Germany, got variable lenghts.
For example, the area code for landlines in Germany is always 5 digits long (4 digits if you're calling from another country). However, for mobile phones it's always 4 digits (3 digits calling from another country).
The actual (local) phone number then can be anything from 3 digits up to 7 or more.
My parents have a telephone they've got ages ago - 4 digits (9 digits total with area code). If I'd get a new contract today, I'd most likely end up with 6 or 7 digits (12+ digits total).
What you could do
Rather than checking for complete numbers, you could try to use a regular expression (see Shekhar's comment above) to verify a proper formatting (e.g. to include the country selection). While this isn't a perfect solution, it should help you avoiding confusing input users left by accident.

How to fetch records without case sensitive in MongoDb? [duplicate]

This question already has answers here:
MongoDB: Is it possible to make a case-insensitive query?
(27 answers)
Closed 8 years ago.
I have a collection like
{
"email" : "sh#Gmail.com"
}
My query should be like , it has to find matching email irrespective of case whether its capital or small but it should match exactly.
In sql we will do like where Lower(strEmail) = Lower(#emailParameterPassed) to satisfy this same.
UPDATE
I got it here.
Thanks
How to achieve this in mongoDb?
I am using c# native driver with mongoDb ?
Nonetheless the answer you are duplicating will give you a correct result, it is not a good idea to do queries like this. Why should you use regex (without indexes ) if you can use normal equal and take advantage of indexes?
There is no difference between sh#Gmail.com and sh#gmail.com so why not to store them in a canonical form in the first place and then to use normal search. To change all the documents, you can refer to my previous answer.

Selection Algorithm to Find Median [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to calculate or approximate the median of a list without storing the list
I want to apply using C# an algorithm to find the median value using selection/quick sort. But I do not want to sort the whole array in order to get the median.
Can I do it?
Wikipedia's entry on Selection Algorithm gives various alternatives, including the Median of Medians approach, which would seem to fit your requirements. In particular, it has a worst-case performance of O(n).

Elegant Algorithm for conversational date strings? [duplicate]

This question already has answers here:
Closed 13 years ago.
Possible Duplicate:
How do I calculate relative time?
Given a DateTime object, what's the most elegant way you've found of converting it to a human friendly string. Something like this:
(Future)
"Tomorrow"
"[1|2|3|4|5|6] days from now."
"Next week"
"Next month"
(Past)
"[1|2|3|4|5|6] days ago."
"Last week"
"Last month"
Thanks.
It's not necessarily the most elegant solution, but this blog article, as well as the the first comment, solve the problem as it pertains to dates in the past. (Copying and pasting the first comment requires replacing the fancy double quotes with plain-old double quotes.)
Stack Overflow just uses cascading if-thens I believe. Can't find the post right now (it's either here or on meta).
EDIT: Jason found it. Link in the comments on the question.

Categories

Resources