Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: string VB.NET table
Hello
 
I need to find the closest string value from an table or array with 13000 record.
 
Is possible to use any function to get the exact or the closest value?
Posted 20-Apr-12 4:31am
Comments
Chauhan_Yatin at 20-Apr-12 10:33am
   
means what u need?? canu explain more that i can try to solve that.??
losmac at 20-Apr-12 11:23am
   
I've had the same problem. Please, take a look at my question and answers. Maybe you'll find an answer...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Probably i need to use this function to compare 2 strings.
 

 

 

 

 
Public Class Distance
 
        ''' <summary>

        ''' Compute Levenshtein distance

        ''' </summary>

        ''' <param name="s">String 1</param>

        ''' <param name="t">String 2</param>

        ''' <returns>Distance between the two strings.

        ''' The larger the number, the bigger the difference.

        ''' </returns>

        Public Function LD(s As String, t As String) As Integer
 
            Dim n As Integer = s.Length
            'length of s
            Dim m As Integer = t.Length
            'length of t
            Dim d As Integer(,) = New Integer(n, m) {}
            ' matrix
            Dim cost As Integer
            ' cost
            ' Step 1

            If n = 0 Then
                Return m
            End If
 
            If m = 0 Then
                Return n
            End If
 
            ' Step 2

            Dim i As Integer = 0
            While i <= n
 

                d(i, 0) = System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
            End While
 
            Dim j As Integer = 0
            While j <= m
 

                d(0, j) = System.Math.Max(System.Threading.Interlocked.Increment(j), j - 1)
            End While
 
            ' Step 3

            For h As Integer = 1 To n
 
                'Step 4

                For f As Integer = 1 To m
 
                    ' Step 5

                    cost = (If(t.Substring(f - 1, 1) = s.Substring(h - 1, 1), 0, 1))
 
                    ' Step 6

 
                    d(h, f) = System.Math.Min(System.Math.Min(d(h - 1, f) + 1, d(h, f - 1) + 1), d(h - 1, f - 1) + cost)
 
                Next
            Next
 

            ' Step 7

 
            Return d(n, m)
 
        End Function
 
    End Class
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Using RegEx could be an approach that you could consider - http://www.dotnetperls.com/regex-match-vbnet[^].
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 370
1 Gihan Liyanage 338
2 ChauhanAjay 180
3 Vinay Mistry 160
4 Sergey Alexandrovich Kryukov 130
0 Sergey Alexandrovich Kryukov 9,011
1 OriginalGriff 7,941
2 CPallini 2,603
3 Richard MacCutchan 2,121
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 20 Apr 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100