Skip to content

Instantly share code, notes, and snippets.

@petervojtek petervojtek/obce.rb
Last active Aug 29, 2015

What would you like to do?
zhlukovanie obci SR podla podobnosti nazvu (jedno pismenko sa moze lisit v ramci danej skupiny)
# encoding: utf-8
villages_full_names ='obce.txt').split "\n"
#villages = ["Ďurkovce", "Hrkovce", "Markovce", "Mirkovce", "Širkovce", "Hokovce"]
villages = villages_full_names.collect{|v| v.sub(/ \/ .+/, '')} # Abrahámovce / okres Bardejov -> Abrahámovce
similar_villages = {}
villages.each_with_index do |village, i|
puts i
villages_similar_to_this_village = []
(0...village.size).to_a.each do |i|
villages_similar_to_this_village_on_position_i = []
village_regexp = village.clone
village_regexp[i] = '.'
villages.each_with_index do |other_village, j|
#puts "village:#{village} #{village_regexp} other_village:#{other_village} #{(village.size != other_village.size).inspect} #{(other_village =~}"
next if village.size != other_village.size
if(other_village =~
villages_similar_to_this_village_on_position_i << villages_full_names[j]
villages_similar_to_this_village << villages_similar_to_this_village_on_position_i
similar_villages[village] = villages_similar_to_this_village
similar_villages = similar_villages.values.flatten(1).select{|a| a.size > 1}.sort{|a,b| a.size <=> b.size}
similar_villages.each {|e| p e}

This comment has been minimized.

Copy link
Owner Author

commented Aug 10, 2014

vitazna skupina:
["Lúčka / okres Roznava", "Lúčka / okres Levoca", "Lúčka / okres Sabinov", "Lúčka / okres Svidnik", "Lúčky / okres Ziar nad Hronom", "Lúčky / okres Michalovce", "Lúčky / okres Ruzomberok"]

druhe a tretie miesto:
["Hankovce / okres Bardejov", "Hankovce / okres humenne", "Jankovce", "Mankovce", "Rankovce"]

["Čebovce", "Čekovce", "Čelovce / okres Presov", "Čelovce / okres Velky krtis", "Čeľovce"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.