Searching For Close Variations

  • Thread starter Thread starter Jordan S.
  • Start date Start date
J

Jordan S.

Using .NET 2.0 (C#) I'm writing a small app that will have a "Person" class
that exposes FirstName and LastName properties. At runtime, a "People"
collection will be populated with a few thousand "Person" objects.

I want to provide users with the ability to search for people by FirstName
and/or LastName.

My question: How can I enable users to search for people with the last name
of [for example] "De Leon". I cannot assume that my users know how to
correctly spell it - so they may be searching with or without the space
(i.e., searching for either "Deleon" or "De Leon").

What are some reasonable/acceptable ways I can search the collection? I'm
wanting to address at least the specifics issue of [spaces within the name].

Thanks!
 
Hey Jordan,

Is the data for people in a Sql Server database? If so, you could
store the value which the Sql Server soundex function returns. Then
you can base you query on searching for values with the same soundex.

HTH
Andy
 
RE:
<< Then you can base you query on ...>>

I'm not querying the db. Instead I want to search the collection of objects
in my app.

Thanks




Andy said:
Hey Jordan,

Is the data for people in a Sql Server database? If so, you could
store the value which the Sql Server soundex function returns. Then
you can base you query on searching for values with the same soundex.

HTH
Andy
Using .NET 2.0 (C#) I'm writing a small app that will have a "Person"
class
that exposes FirstName and LastName properties. At runtime, a "People"
collection will be populated with a few thousand "Person" objects.

I want to provide users with the ability to search for people by
FirstName
and/or LastName.

My question: How can I enable users to search for people with the last
name
of [for example] "De Leon". I cannot assume that my users know how to
correctly spell it - so they may be searching with or without the space
(i.e., searching for either "Deleon" or "De Leon").

What are some reasonable/acceptable ways I can search the collection? I'm
wanting to address at least the specifics issue of [spaces within the
name].

Thanks!
 
Jordan,

You can implement a soundex function in your code easily. Here is a web
page that goes into it in some detail:

http://www.creativyst.com/Doc/Articles/SoundEx1/SoundEx1.htm

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Jordan S. said:
RE:
<< Then you can base you query on ...>>

I'm not querying the db. Instead I want to search the collection of
objects in my app.

Thanks




Andy said:
Hey Jordan,

Is the data for people in a Sql Server database? If so, you could
store the value which the Sql Server soundex function returns. Then
you can base you query on searching for values with the same soundex.

HTH
Andy
Using .NET 2.0 (C#) I'm writing a small app that will have a "Person"
class
that exposes FirstName and LastName properties. At runtime, a "People"
collection will be populated with a few thousand "Person" objects.

I want to provide users with the ability to search for people by
FirstName
and/or LastName.

My question: How can I enable users to search for people with the last
name
of [for example] "De Leon". I cannot assume that my users know how to
correctly spell it - so they may be searching with or without the space
(i.e., searching for either "Deleon" or "De Leon").

What are some reasonable/acceptable ways I can search the collection?
I'm
wanting to address at least the specifics issue of [spaces within the
name].

Thanks!
 
Well, the principal would be the same. You'll need to locate something
like the soundex() function on Sql server and implement it in your
code. Then loop though the collection and match anyone that has a
similar soundex value.

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top