dupecop bad replica

VBnetster

Active member
Joined
Feb 15, 2008
Messages
32
Programming Experience
Beginner
hi!

ahwell this was going good, I thought i figured it out. A replica of http://www.dupecop.com/images/desktop-screenshot-large.gif

But after a little testing it's obvious mine si 100% not working right :rolleyes:

Here's the code:

VB.NET:
    Private Sub btn_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn.Click
        Dim Ntxt As String = "my name is sean and this is my old text" 'the new text
        Dim Otxt As String = "my name is sean and this is my old text" 'the original
        Dim Anew() As String
        Dim Aold() As String
        Dim rate As Integer = 0%
        Dim percent As Integer = 100%
        Dim result As String
        Anew = Split(Ntxt, " ")
        Aold = Split(Otxt, " ")

        ' the following comparing routine is the best but worst i could think of
        For i = 1 To UBound(Anew)
            If Anew(i) = Nothing Then GoTo done
            For x = 1 To UBound(Aold)
                If Not Anew(i) Like Aold(x) Then
                    rate += 1%
                End If
            Next
        Next
done:
        If Len(percent / rate) > 4 Then
            result = Mid((percent / rate), 1, 4)
        Else
            result = (percent / rate)
        End If

        If result < 20% Then
            MsgBox("your new input is now " & result & "% like the original, good job!")
        Else
            MsgBox("your new input is now " & result & "% like the original, I suggest you work a little harder.")
        End If

    End Sub

even when new string and original string are exactly the same, im still being told they are different. huh ? :confused:
 
Here's a basic version, matches all words once and checks what's left of new text:
VB.NET:
Sub wordmatch()
    Dim Ntxt As String = "hi my name is sean and this is my old text" 'the new text
    Dim Otxt As String = "my name is sean and this is my old text" 'the original
    Dim Anew As New List(Of String)(Ntxt.Split(" "c))
    Dim Aold As New List(Of String)(Otxt.Split(" "c))
    Dim totalnew As Integer = Anew.Count
    For Each word In Aold            
        Anew.Remove(word)
    Next

    Dim result As Single = 1 - (Anew.Count / totalnew)
    Dim resultmessage = String.Format("your new input is now {0} like the original, ", result.ToString("p"))

    If result < 0.2 Then
        MsgBox(resultmessage & "good job!")
    Else
        MsgBox(resultmessage & "I suggest you work a little harder.")
    End If
End Sub
Maybe it should be the other way around, eliminating old text and see what's left of that? (to see if all original words was used and new added.)
 
the code does work fine.. but is there a way i can change it so instead of it saying like 80% it would say 20% unique? so basically "result - 100" would say that its 20% original. instead of its 80% different. it's kinda backwards

hope that makes sense?
 
Yes, just change the "result" calculation. Value 1 is 100%.
 
Back
Top