Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. def full_search(offensive_list)
  2. p 'Full check:'
  3. p "Comparing #{$all_vehicles.count} records against #{offensive_list.count} banned combinations"
  4. p 'This will take a few minutes'
  5. vrm_array, example_array = [], []
  6. vrm_list = $all_vehicles.keys.sort
  7. vrm_list.each do |vrm|
  8. vrm_array << vrm.split("") #We split each reg into an array of characters
  9. end
  10. offensive_list.each do |example|
  11. example.strip!
  12. example_array << example.split("") #and the same with our banned combinations
  13. end
  14.  
  15. vrm_array.each do |vrm|
  16. example_array.each do |example| #itterate through vrms x examples
  17. @formatted_vrm = vrm.dup
  18. if example.length == vrm.length
  19. example.each_index do |index|
  20. if example[index] == "?" #for each wildcard we add a wildcard to the vrm for comparison
  21. @formatted_vrm[index] = "?"
  22. end
  23. end
  24. if @formatted_vrm == example then offensive_found(vrm, example) end
  25. end
  26. end
  27. end
  28. end
  29.  
  30. def offensive_found(vrm, example)
  31. built_vrm = ""
  32. built_example = ""
  33. if vrm.class == Array #clean up formatting so we can store it
  34. vrm.each do |character|
  35. built_vrm << character
  36. end
  37. example.each do |character|
  38. built_example << character
  39. end
  40. else
  41. built_example = example #clearly redundant, but it works so...
  42. built_vrm = vrm
  43. end
  44.  
  45. if $bad_vrms[built_example] # if we already have a record
  46. prev_matched = $bad_vrms[built_example] #just add to the array
  47. prev_matched << built_vrm
  48. $bad_vrms.store(built_example, prev_matched)
  49. else
  50. new_match = [built_vrm] # or create a new hash key
  51. $bad_vrms.store(built_example, new_match)
  52. end
  53. #p "#{built_vrm} - matched with #{built_example}"
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement