Skip to content

Commit 0dbe53a

Browse files
committed
Upgraded parsing logic to yield more accurate results (more true positives and negatives, fewer false positives and negatives)
1 parent 6426da5 commit 0dbe53a

File tree

1 file changed

+45
-8
lines changed

1 file changed

+45
-8
lines changed

WindowsApp1/WikiHandler.vb

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,36 @@ Public Class WikiHandler
4848

4949
For Each s In gameName
5050
Dim n = Regex.Replace(s, "[^\p{L}a-zA-Z0-90]", "")
51-
strippedgameName.Add(n.ToLower)
51+
strippedgameName.Add(n.ToLower.Trim)
5252
Next
5353

5454

55-
Dim i = 0
56-
Dim gcount As New List(Of Integer)
5755

56+
Dim gcount As New List(Of Integer)
5857

59-
For Each a In strippedgameName
60-
If a.ToString.Contains(workingname) Then
61-
gcount.Add(i)
58+
If ParseLogic(strippedgameName, workingname) = True Then
59+
Dim i = 0
60+
If isExactMatch = True Then
61+
For Each a In strippedgameName
62+
If a.Equals(workingname) And workingname.Length > 1 Then gcount.Add(i)
63+
i += 1
64+
Next
65+
Else
66+
For Each a In strippedgameName
67+
If a.ToString.StartsWith(workingname) And Math.Abs(a.ToString.Length - workingname.Length) < 5 And workingname.Length > 1 Then gcount.Add(i)
68+
i += 1
69+
Next
6270
End If
63-
i += 1
64-
Next
71+
72+
Else
73+
Dim i = 0
74+
For Each a In strippedgameName
75+
If workingname.Length > 5 Then
76+
If a.ToString.Contains(workingname) Then gcount.Add(i)
77+
End If
78+
i += 1
79+
Next
80+
End If
6581

6682

6783
WikiPopup.GamesTable.Visible = False
@@ -141,6 +157,27 @@ Public Class WikiHandler
141157
End Sub
142158

143159

160+
161+
162+
Shared isExactMatch As Boolean
163+
Shared Function ParseLogic(online_R As List(Of String), local_R As String) As Boolean
164+
isExactMatch = False
165+
Dim success = 0
166+
For Each a In online_R
167+
If a.StartsWith(local_R) And Math.Abs(a.Length - workingname.Length) < 5 Then
168+
If a.Length = workingname.Length Then isExactMatch = True
169+
success = 1
170+
Return True
171+
Exit For
172+
End If
173+
Next
174+
175+
If success = 0 Then Return False
176+
177+
End Function
178+
179+
180+
144181
Shared firstGame As Integer = 0
145182
Private Shared Sub FillTable(ps As Integer)
146183

0 commit comments

Comments
 (0)