Sie sind auf Seite 1von 5

Damerau Levenshtein Algorithm by R.G. Code: 5,176,906. lines Jobs: 294.

postings Visual Basic Stats:How to support the siteSponsored by: .Net (VB and C#)PHPJavascriptJavaC/C++SQLPerlASP classicVB classicDelphiCold FusionCode/Articles NewestBrowse categoriesSearch-----------------------Upload code / articlesOpen letter from moderators-----------------------Articles & tutorialsRecommended readingTop Code Coding contestCoding contest leader boardCoding contest 'All-Time Hall of Fame'-----------------------Code of the day newsletterCommunity Ask a pro discussion forumGamesCode of the day newsletterJobs Search for a jobPost a jobOther My profileHow to link to usAwards/Reviews/Raves!Advertising/Media kitFeedbackAbout the siteGoto Visual Basic homeSite homeOther sites Site Wide Message: (current site time 10/27/2010 7:27:05 PM EDT) Planet Source Code is now virtual and converted over to a cloud computing environment! Thanks for your patience during the move. Damerau Levenshtein Algorithm Print Email

Submitted on: 12/28/2008 3:58:04 PM By: R.G. Level: Advanced User Rating: Unrated Compatibility:VB 6.0, VB Script, VBA MS Excel Users have accessed this code 3652 times.

This function returns the Levenshtein distance capped by the limit parameter.

code: Can't Copy and Paste this? Click here for a copy-and-paste friendly version of this code! Terms of Agreement: By using this code, you agree to the following terms... You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws. You may link to this code from another website, but ONLY if

it is not wrapped in a frame. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description. '************************************** ' Name: Damerau Levenshtein Algorithm ' Description:This function returns the Levenshtein distance capped by the limit parameter. ' By: R.G. ' 'This code is copyrighted and has' limited warranties.Please see http://www.Plan et-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=71576&lngWId=1'for details. '************************************** 'Debug.Print damerau_levenshtein("Alexander (2004)", "Alexander", 10) Function damerau_levenshtein(s1 As String, s2 As String, Optional limit As Varia nt, Optional result As Variant) As Integer 'This function returns the Levenshtein distance capped by the limit parameter. Dim Dim Dim Dim Dim diagonal As Integer horizontal As Integer vertical As Integer swap As Integer final As Integer

'set a maximum limit if not set If IsMissing(limit) Then limit = Len(s1) + Len(s2) End If 'create the result matrix to store intermediary results If IsMissing(result) Then Dim i, j As Integer ' pointeur ReDim result(Len(s1), Len(s2)) As Integer End If 'Start of the strings analysis If result(Len(s1), Len(s2)) < 1 Then If Abs(Len(s1) - Len(s2)) >= limit Then final = limit Else If Len(s1) = 0 Or Len(s2) = 0 Then 'End of recursivity final = Len(s1) + Len(s2) Else 'Core of levenshtein algorithm If Mid(s1, 1, 1) = Mid(s2, 1, 1) Then final = damerau_levenshtein(Mid(s1, 2), Mid(s2, 2), limit, result) Else If Mid(s1, 1, 1) = Mid(s2, 2, 1) And Mid(s1, 2, 1) 'Damerau extension counting swapped letters swap = damerau_levenshtein(Mid(s1, 3), Mid(s2, 3), final = 1 + swap Else 'The function minimum is implemented via the limit 'The diagonal search usually reaches the limit the = Mid(s2, 1, 1) Then limit - 1, result) parameter. quickest.

diagonal = damerau_levenshtein(Mid(s1, 2), Mid(s2, 2), limit - 1, result) horizontal = damerau_levenshtein(Mid(s1, 2), s2, diagonal, result) vertical = damerau_levenshtein(s1, Mid(s2, 2), horizontal, result) final = 1 + vertical End If End If End If End If Else 'retrieve intermediate result final = result(Len(s1), Len(s2)) - 1 End If 'returns the distance capped by the limit If final < limit Then damerau_levenshtein = final 'store intermediate result result(Len(s1), Len(s2)) = final + 1 Else damerau_levenshtein = limit End If End Function

Other 2 submission(s) by this author Report Bad Submission Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.). This submission should be removed because: Your Vote! What do you think of this code(in the Advanced category)? (The code with your highest vote will win this month's coding contest!) Excellent Good Average Below Average Poor See Voting Log Other User Comments There are no comments on this submission.

Add Your Feedback!

Note:Not only will your feedback be posted, but an email will be sent to the code's author from the email account you registered on the site, so you can correspond directly. NOTICE: The author of this code has been kind enough to share it with you.

If you have a criticism, please state it politely or it will be deleted. For feedback not related to this particular code, please click here. Name:Khan Farhan Email:tania2k12000@yahoo.com Comment: Quick search for Choose Language .Net ASP / VbScript C / C++ Cold Fusion Delphi Java Javascript Perl PHP SQL Visual Basic Search Term Search Welcome Khan Farhan Logout Latest postings for Visual Basic. Inventory System v1.0 By Joeland A. Togonon on 10/26 (Screen Shot)TASK BAR WITH SEVERAL SOFTWARE By Rajesh Shrestha on 10/25 Video Surveilance program. Creates/stores AVI files on motion detection. No activex or OCX controls. By Ivan Enriquez on 10/20 (Screen Shot)City Master By Gursahib Singh on 10/20 VB6 Standard DLL .def Generator [Update 10-20-2010!] By Jonell T. Vermudez on 10/20 (Screen Shot)University Timetabling System By Leomar V. Ramos on 10/20 (Screen Shot)Count Lines of code 20-Oct-2010 By Kenaso on 10/20 (Screen Shot)Student Records Software By krishan verma on 10/20 Student Record By Gursahib Singh on 10/20 card magic game By Rajesh Shrestha on 10/17 TimerCount By Ernesto F. on 10/16 (Screen Shot)MP3 Library + TagEditor By mahesh Kurmi on 10/15 (Screen Shot)borkywarp By Oddacon T Ripper on 10/14 (Screen Shot)Ole2010FileMove r/w/Acellerator BETARodLewis201 0Ole2010FileMov er/w/Acellerato rBETARodLewis20 10 By ROD LEWIS on 10/14 (Screen Shot)BUDGET HOME (UR FINANCE MINISTER) By M BALAJI on 10/12 EXCEL TO ACCES CONVERTER By M BALAJI on 10/12 ACCESS TO MYSQL CONVERTER By M BALAJI on 10/12 EMAIL THRU VB 6.0 USING ADDRESSES FROM ACCESS WITH ATTACHMENTS ALSO By M BALAJI on 10/12 Add Bitmap to Menus By Abhishek.NET on 10/12 (Screen Shot)Disable / Enable DEP By Abhishek.NET on 10/12 Simple VB6 Coloured Code Browser and Printer By Dave Carter on 10/11 (Screen Shot)Disable Mousewheel Scroll in ComboBox By Porthos on 10/11 (Screen Shot)Active Data Objects Example By Hamza Tassaddaq on 10/11 (Screen Shot)Binding DataGrid to ADODC By Kivan Cantimur on 10/10 CryptoAPI SHA2 Hash 10-Oct-2010 By Kenaso on 10/10 (Screen Shot) Click here to put this ticker

on your site! Add to Active Desktop Add this ticker to your desktop!Daily Code Email Click here to join the 'Code of the Day' mailing list! This Site on CD Over 7,000 submissions on a super fast CD! Get Paid To Code Now taking registrations on Rent a Coder!

Open letter from moderatorsAbout the siteFeedbackLink to the SiteAwardsAdvertisingPrivacy Code/Articles Newest Browse categories Search Upload code / articles Open letter from moderators Articles & tutorials Recommended reading Top Code Coding contest Coding contest leader board Coding contest 'All-Time Hall of Fame' Code of the day newsletterCommunity Ask a pro discussion forum Games Code of the day newsletter Jobs Search for a job Post a job Other My profile How to link to us Awards/Reviews/Raves! Advertising/Media kit Feedback About the site Goto Visual Basic home Site home Other sitesCopyright 1997-2010 by Exhedra Solutions, Inc. All Rights Reserved.By using this site you agree to its Terms and Conditions. Planet Source Code and the phrase "Dream It. Code It" are trademarks of Exhedra Solutions, Inc.

Das könnte Ihnen auch gefallen