dmetaphone_demo.zip
ASPWordDBLookup
CSWordLookup
App.ico
bin
Release
CSWordLookup.exe
Metaphone.NET.dll
obj
Release
temp
namelist.mdb
VBScriptWordLookup
VBWordDBLookup
frmMain.frm
MSSCCPRJ.SCC
VBWordDBLookup.vbp
VBWordDBLookup.vbw
VBWordLookup.exe
VBWordLookup
frmMain.frm
MSSCCPRJ.SCC
VBWordLookup.exe
VBWordLookup.vbp
VBWordLookup.vbw
WordLookupSample
Release
WordLookupSample.exe
dmetaphone_demo1.zip
App.ico
namelist.mdb
VBScriptWordLookup.vbs.fascistemailclient
frmMain.frm
MSSCCPRJ.SCC
VBWordDBLookup.vbp
VBWordDBLookup.vbw
frmMain.frm
MSSCCPRJ.SCC
VBWordLookup.vbp
VBWordLookup.vbw
dmetaphone_src.zip
Metaphone.NET
bin
Debug
Release
Metaphone.NET.dll
Metaphone.NET.bakvpj
Metaphone.NET.csproj.user
Metaphone.NET.vpj
obj
Debug
temp
TempPE
Release
temp
TempPE
MetaphoneCOM
Debug
MetaphoneCOM.aps
MetaphoneCOM.bakvpj
MetaphoneCOM.rgs
MetaphoneCOM.vpj
MetaphoneCOMps.def
MetaphoneCOMPS.vpj
Release
MetaphoneCOM.dll
MetaphoneCOM.exp
MetaphoneCOM.lib
MetaphoneCOM.res
MetaphoneLib
Debug
MetaphoneLib.bakvpj
MetaphoneLib.vpj
Release
DoubleMetaphone.obj
MetaphoneLib.lib
stdafx.obj
XPMetaphone
Debug
Release
XPMetaphone.dll
XPMetaphone.exp
XPMetaphone.lib
XPMetaphone.obj
XPMetaphone.res
XPMetaphone.aps
XPMetaphone.bakvpj
XPMetaphone.vpj
dmetaphone_src1.zip
Metaphone.NET.bakvpj
Metaphone.NET.csproj.user
Metaphone.NET.vpj
MetaphoneCOM.aps
MetaphoneCOM.bakvpj
MetaphoneCOM.rgs
MetaphoneCOM.vpj
MetaphoneCOMps.def
MetaphoneCOMPS.vpj
Test.vbs.braindeademailclient
MetaphoneLib.bakvpj
MetaphoneLib.vpj
XPMetaphone.bakvpj
XPMetaphone.vpj
|
/**
* DoubleMetaphoneShort.cpp
*
* Implementation of the Double Metaphone phonetic matching algorithm, wrapped as a dual-interface
* COM component callable from Visual Basic and scripting clients. This implementation exposes
* the metaphone keys as shorts instead of strings, for even more efficient storage and retrieval.
*
* For the latest version, implemenatations for other languages, and links to articles
* I've written on how to use this and all my other Double Metaphone implementations, go to
* http://www.nullpointer.net/anelson/
*
* Current Version: 1.0.0
* Revision History:
* 1.0.0 - ajn - First release
*
* Implementation by Adam J. Nelson (anelson@nullpointer.net)
* Copyright (C) 2003 Adam J. Nelson, All Rights Reserved
*
* The Double Metaphone algorithm was written by Lawrence Phillips, and is
* Copyright (c) 1998, 1999 by Lawrence Philips.
**/
#include "stdafx.h"
#include "DoubleMetaphoneShort.h"
STDMETHODIMP DoubleMetaphoneShort::ComputeMetaphoneKeys(/*[in]*/ BSTR Word, /*[out]*/ short* PrimaryKey, /*[out]*/ short* AlternateKey) {
//Simply pass the call along to a ShortDoubleMetaphone instance
ShortDoubleMetaphone mphone(Word);
*PrimaryKey = mphone.getPrimaryShortKey();
if (mphone.getAlternateKey()) {
*AlternateKey = mphone.getAlternateShortKey();
} else {
*AlternateKey = static_cast<short>(METAPHONE_INVALID_KEY);
}
return S_OK;
}
STDMETHODIMP DoubleMetaphoneShort::CompareMetaphoneKeys(/*[in]*/ short PrimaryKey1, /*[in]*/ short AlternateKey1, /*[in]*/ short PrimaryKey2, /*[in]*/ short AlternateKey2, /*[out, retval]*/ VARIANT_BOOL* Result) {
if (
(PrimaryKey1 == PrimaryKey2) ||
(AlternateKey2 != METAPHONE_INVALID_KEY && PrimaryKey1 == AlternateKey2) ||
(AlternateKey1 != METAPHONE_INVALID_KEY && AlternateKey1 == PrimaryKey2) ||
(AlternateKey1 != METAPHONE_INVALID_KEY && AlternateKey2 != METAPHONE_INVALID_KEY && AlternateKey1 == AlternateKey2)
) {
*Result = VARIANT_TRUE;
} else {
*Result = VARIANT_FALSE;
}
return S_OK;
}
/** ComputeMetaphoneKeys, but using only IDispatch-compatible types for use with VBScript/JScript/etc */
STDMETHODIMP DoubleMetaphoneShort::ComputeMetaphoneKeysScr(/*[in]*/ BSTR Word, /*[out]*/ VARIANT* PrimaryKey, /*[out]*/ VARIANT* AlternateKey) {
short prime, alt;
ComputeMetaphoneKeys(Word, &prime, &alt);
::VariantInit(PrimaryKey);
::VariantInit(AlternateKey);
V_VT(PrimaryKey) = VT_I2;
PrimaryKey->iVal = prime;
if (alt != METAPHONE_INVALID_KEY) {
V_VT(AlternateKey) = VT_I2;
AlternateKey->iVal = alt;
} else {
V_VT(AlternateKey) = VT_NULL;
}
return S_OK;
}
|
By viewing downloads associated with this article you agree to the Terms of use 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.
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.