Click here to Skip to main content
15,867,771 members
Articles / Mobile Apps / Windows Mobile

Implement Phonetic ("Sounds-like") Name Searches with Double Metaphone Part V: .NET Implementation

Rate me:
Please Sign up or sign in to vote.
4.74/5 (18 votes)
19 Mar 20076 min read 275.2K   5.2K   103  
Presents a C# implementation of Double Metaphone, for use with any of the .NET languages.
import "D:\Programming\SDKs\Microsoft Platform SDK\Include\prsht.idl";
import "D:\Programming\SDKs\Microsoft Platform SDK\Include\mshtml.idl";
import "d:\programming\sdks\microsoft platform sdk\include\dimm.idl";
import "D:\Programming\SDKs\Microsoft Platform SDK\Include\mshtmhst.idl";
import "d:\programming\sdks\microsoft platform sdk\include\docobj.idl";
import "D:\Programming\SDKs\Microsoft Platform SDK\Include\exdisp.idl";
import "D:\Programming\SDKs\Microsoft Platform SDK\Include\objsafe.idl";

[
	object,
	uuid(8DDA7DB4-1548-4E71-B9F7-EB6714A5CD07),
	dual,
	helpstring("IDoubleMetaphoneShort Interface"),
	pointer_default(unique)
] 
#line 14 "z:\\projects\\personal\\metaphone\\metaphonecom\\doublemetaphoneshort.h"
interface IDoubleMetaphoneShort : IDispatch {
#line 16 "z:\\projects\\personal\\metaphone\\metaphonecom\\doublemetaphoneshort.h"
	HRESULT  ComputeMetaphoneKeys([in] BSTR Word, [out] short *PrimaryKey, [out] short *AlternateKey);
	HRESULT  CompareMetaphoneKeys([in] short PrimaryKey, [in] short AlternateKey1, [in] short PrimaryKey2, [in] short AlternateKey2, [out,retval] VARIANT_BOOL *Result);
#line 19 "z:\\projects\\personal\\metaphone\\metaphonecom\\doublemetaphoneshort.h"
	HRESULT  ComputeMetaphoneKeysScr([in] BSTR Word, [out] VARIANT *PrimaryKey, [out] VARIANT *AlternateKey);
};

[
	object,
	uuid(CF4FA34B-FDB2-42A5-8DD0-38338FC46320),
	dual,
	helpstring("IDoubleMetaphoneString Interface"),
	pointer_default(unique)
] 
#line 14 "z:\\projects\\personal\\metaphone\\metaphonecom\\doublemetaphonestring.h"
interface IDoubleMetaphoneString : IDispatch {
#line 16 "z:\\projects\\personal\\metaphone\\metaphonecom\\doublemetaphonestring.h"
	HRESULT  ComputeMetaphoneKeys([in] BSTR Word, [out] BSTR *PrimaryKey , [out] BSTR *AlternateKey );
	HRESULT  CompareMetaphoneKeys([in] BSTR PrimaryKey, [in] BSTR AlternateKey1, [in] BSTR PrimaryKey2, [in] BSTR AlternateKey2, [out,retval] VARIANT_BOOL *Result);
#line 19 "z:\\projects\\personal\\metaphone\\metaphonecom\\doublemetaphonestring.h"
	HRESULT  ComputeMetaphoneKeysScr([in] BSTR Word, [out] VARIANT *PrimaryKey, [out] VARIANT *AlternateKey);
};


[ version(1.0), uuid(845FE5AF-CC53-4C37-9464-EE20A866B9B0), helpstring("Adam J. Nelson's Double Metaphone Implementations") ]
library MetaphoneCOM
{
	importlib("stdole2.tlb");
	importlib("olepro32.dll");

	[
		version(1.0),
		uuid(C762BBEB-9D86-4988-BB7E-3A9963249AB6),
		helpstring("Adam J. Nelson's Double Metaphone Short Implementation")
	] 
#line 35 "z:\\projects\\personal\\metaphone\\metaphonecom\\doublemetaphoneshort.h"
	coclass DoubleMetaphoneShort {
		interface IDoubleMetaphoneShort;
	};

	[
		version(1.0),
		uuid(EDDED454-8E77-472D-9AAC-D690AFDF2BCB),
		helpstring("Adam J. Nelson's Double Metaphone String Implementation")
	] 
#line 35 "z:\\projects\\personal\\metaphone\\metaphonecom\\doublemetaphonestring.h"
	coclass DoubleMetaphoneString {
		interface IDoubleMetaphoneString;
	};

	[
		custom(8AFCDA7F-33B7-3120-86A8-754D2C0C0578, "library_block")
	] 
#line 15 "z:\\projects\\personal\\metaphone\\metaphonecom\\metaphonecom.cpp"
	enum MetaphoneKey {
		Invalid = -1,
	};

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
My name is Adam Nelson. I've been a professional programmer since 1996, working on everything from database development, early first-generation web applications, modern n-tier distributed apps, high-performance wireless security tools, to my last job as a Senior Consultant at BearingPoint posted in Baghdad, Iraq training Iraqi developers in the wonders of C# and ASP.NET. I am currently an Engineering Director at Dell.

I have a wide range of skills and interests, including cryptography, image processing, computational linguistics, military history, 3D graphics, database optimization, and mathematics, to name a few.

Comments and Discussions