#a = [['ACRA','acra',67.3333333333333333,119,33,9.5118733509234828,600.8333333333333333,1503,183,4.5175438596491228,52,1,13.9310344827586207,229,1,13.9310344827586207,229,1,3605,1309,6,2010,2015,404,'long',"low rate",'small'],['apache','storm',489.0000000000000000,948,118,24.0331412103746398,10007.4000000000000000,26526,2152,5.9250444049733570,314,1,15.4746835443037975,622,1,15.4746835443037975,622,1,50037,14599,5,2011,2015,2445,'long',"high rate",'large'], ['facebook','fresco',313.0000000000000000,313,313,14.7295373665480427,4139.0000000000000000,4139,4139,1.4909942363112392,33,1,156.5000000000000000,269,44,156.5000000000000000,269,44,4139,3463,1,2015,2015,313,'medium',"high rate",'medium'], ['square','dagger',99.2000000000000000,236,4,13.6963123644251627,1578.5000000000000000,3374,171,5.6425379803395889,65,1,16.0000000000000000,157,1,16.0000000000000000,157,1,6314,1827,5,2012,2016,496,'long',"low rate",'small'], ['deeplearning4j','deeplearning4j',880.7500000000000000,2018,65,24.3333333333333333,20549.500000000000,35869,4377,5.6860819037078030,345,1,65.2407407407407407,1987,1,65.2407407407407407,1987,1,82198,29896,4,2013,2016,3523,'long',"very high rate",'large'], ['koush','ion',130.0000000000000000,253,7,8.8174442190669371,1086.7500000000000000,2315,24,3.3132621951219512,161,1,40.0000000000000000,492,1,40.0000000000000000,492,1,4347,1678,4,2013,2016,520,'long','medium','small'], ['greenrobot','greenDAO',69.1666666666666667,137,5,21.8354430379746835,1437.5000000000000000,2971,34,3.9401553220648698,63,1,138.3333333333333333,367,1,138.3333333333333333,367,1,8625,4089,6,2011,2016,415,'long',"low rate",'medium'], ['prestodb','tempto',149.0000000000000000,253,45,11.9646643109540636,1693.0000000000000000,3073,313,1.8842515303283250,44,1,16.5555555555555556,66,1,16.5555555555555556,66,1,3386,2422,2,2015,2016,298,'medium','medium','medium'], ['google','blockly-android',345.5000000000000000,690,1,14.8223583460949464,4839.5000000000000000,9543,136,4.6803675048355899,90,1,98.7142857142857143,538,1,98.7142857142857143,538,1,9679,3608,2,2015,2016,691,'medium',"high rate",'medium'], ['perwendel','spark',91.8333333333333333,171,22,18.2714570858283433,1525.6666666666666667,2818,277,3.9153122326775021,72,1,7.2500000000000000,277,1,7.2500000000000000,277,1,9154,3117,6,2011,2016,551,'long',"low rate",'medium'], ['Netflix','governator',124.2000000000000000,159,75,19.0365217391304348,2189.2000000000000000,3324,1066,4.1073170731707317,263,1,24.8400000000000000,316,1,24.8400000000000000,316,1,10946,4229,5,2012,2016,621,'long','medium','medium'], ['gabrielemariotti','cardslib',109.0000000000000000,223,3,16.6840390879478827,1707.3333333333333333,3340,19,3.2812299807815503,95,1,46.7142857142857143,285,1,46.7142857142857143,285,1,5122,3940,3,2013,2015,327,'long','medium','medium'], ['amlcurran','ShowcaseView',66.4000000000000000,141,6,8.6193548387096774,534.4000000000000000,1156,74,5.8984547461368653,70,1,10.7096774193548387,215,1,10.7096774193548387,215,1,2672,927,5,2012,2016,332,'long',"low rate",'small'], ['johncarl81','parceler',57.0000000000000000,76,41,14.7177033492822967,769.0000000000000000,1151,516,2.4316205533596838,31,1,45.6000000000000000,217,1,45.6000000000000000,217,1,3076,1619,4,2013,2016,228,'long',"low rate",'small'], ['mapstruct','mapstruct',120.8000000000000000,288,7,19.0373831775700935,2037.0000000000000000,4462,201,2.0357785328802718,81,1,54.9090909090909091,334,1,54.9090909090909091,334,1,10185,7885,5,2012,2016,604,'long','medium','medium'], ['skylot','jadx',120.0000000000000000,208,11,19.6252631578947368,2330.5000000000000000,3915,248,2.4069197004905758,197,1,43.6363636363636364,436,1,43.6363636363636364,436,1,9322,6012,4,2013,2016,480,'long','medium','medium'], ['Atmosphere','nettosphere',67.2000000000000000,118,5,9.0126182965299685,571.4000000000000000,1074,10,4.3685015290519878,46,1,37.3333333333333333,322,1,37.3333333333333333,322,1,2857,1112,5,2012,2016,336,'long',"low rate",'small'], ['gridgain','yardstick',106.5000000000000000,208,5,6.3664921465968586,608.0000000000000000,1163,53,3.6516516516516517,62,1,23.6666666666666667,137,1,23.6666666666666667,137,1,1216,512,2,2014,2015,213,'medium','medium','small'], ['arquillian','arquillian-core',59.1250000000000000,175,6,15.1986301369863014,832.1250000000000000,3421,55,2.0289545870161536,110,1,36.3846153846153846,420,1,36.3846153846153846,420,1,6657,5563,8,2009,2016,473,'long',"low rate",'medium'], ['haifengl','smile',79.0000000000000000,121,6,18.4714285714285714,1293.0000000000000000,1918,872,1.8559808612440191,24,1,19.7500000000000000,155,1,19.7500000000000000,155,1,3879,3885,3,2014,2016,237,'long',"low rate",'medium'], ['orfjackal','retrolambda',68.7500000000000000,133,24,9.9538461538461538,647.0000000000000000,1501,212,3.0591016548463357,83,1,25.0000000000000000,237,1,25.0000000000000000,237,1,2588,1111,4,2013,2016,275,'long',"low rate",'small'], ['kevinsawicki','http-request',54.6000000000000000,108,5,6.7181467181467181,348.0000000000000000,752,14,2.5588235294117647,50,1,39.0000000000000000,267,1,39.0000000000000000,267,1,1740,726,5,2011,2015,273,'long',"low rate",'small'], ['openzipkin','brave',84.2500000000000000,108,56,26.9758620689655172,1955.7500000000000000,3300,1038,4.2378114842903575,83,1,14.6521739130434783,225,1,14.6521739130434783,225,1,7823,4204,4,2013,2016,337,'long',"low rate",'medium']]

a = [['ACRA', 'acra', 67.3333333333333333, 119, 33, 9.5118733509234828, 600.8333333333333333, 1503, 183, 4.5175438596491228, 52, 1, 13.9310344827586207, 229, 1, 13.9310344827586207, 229, 1, 3605, 1309, '2010-04-18', '2015-06-05', 6, 2010, 2015, 404, 'long', 'low', 'small'], ['apache', 'storm', 489.0000000000000000, 948, 118, 24.0331412103746398, 10007.4000000000000000, 26526, 2152, 5.9250444049733570, 314, 1, 15.4746835443037975, 622, 1, 15.4746835443037975, 622, 1, 50037, 14599, '2011-09-16', '2015-12-28', 5, 2011, 2015, 2445, 'long', 'high', 'large'], ['facebook', 'fresco', 313.0000000000000000, 313, 313, 14.7295373665480427, 4139.0000000000000000, 4139, 4139, 1.4909942363112392, 33, 1, 156.5000000000000000, 269, 44, 156.5000000000000000, 269, 44, 4139, 3463, '2015-03-26', '2015-10-30', 1, 2015, 2015, 313, 'medium', 'high', 'medium'], ['square', 'dagger', 99.2000000000000000, 236, 4, 13.6963123644251627, 1578.5000000000000000, 3374, 171, 5.6425379803395889, 65, 1, 16.0000000000000000, 157, 1, 16.0000000000000000, 157, 1, 6314, 1827, '2012-06-25', '2016-01-30', 5, 2012, 2016, 496, 'long', 'low', 'small'], ['deeplearning4j', 'deeplearning4j', 880.7500000000000000, 2018, 65, 24.3333333333333333, 20549.500000000000, 35869, 4377, 5.6860819037078030, 345, 1, 65.2407407407407407, 1987, 1, 65.2407407407407407, 1987, 1, 82198, 29896, '2013-11-27', '2016-02-13', 4, 2013, 2016, 3523, 'long', 'very' 'high', 'large'], ['koush', 'ion', 130.0000000000000000, 253, 7, 8.8174442190669371, 1086.7500000000000000, 2315, 24, 3.3132621951219512, 161, 1, 40.0000000000000000, 492, 1, 40.0000000000000000, 492, 1, 4347, 1678, '2013-05-22', '2016-06-14', 4, 2013, 2016, 520, 'long', 'medium', 'small'], ['greenrobot', 'greenDAO', 69.1666666666666667, 137, 5, 21.8354430379746835, 1437.5000000000000000, 2971, 34, 3.9401553220648698, 63, 1, 138.3333333333333333, 367, 1, 138.3333333333333333, 367, 1, 8625, 4089, '2011-07-28', '2016-05-23', 6, 2011, 2016, 415, 'long', 'low', 'medium'], ['prestodb', 'tempto', 149.0000000000000000, 253, 45, 11.9646643109540636, 1693.0000000000000000, 3073, 313, 1.8842515303283250, 44, 1, 16.5555555555555556, 66, 1, 16.5555555555555556, 66, 1, 3386, 2422, '2015-03-06', '2016-06-20', 2, 2015, 2016, 298, 'medium', 'medium', 'medium'], ['google', 'blockly-android', 345.5000000000000000, 690, 1, 14.8223583460949464, 4839.5000000000000000, 9543, 136, 4.6803675048355899, 90, 1, 98.7142857142857143, 538, 1, 98.7142857142857143, 538, 1, 9679, 3608, '2015-07-23', '2016-06-23', 2, 2015, 2016, 691, 'medium', 'high', 'medium'], ['perwendel', 'spark', 91.8333333333333333, 171, 22, 18.2714570858283433, 1525.6666666666666667, 2818, 277, 3.9153122326775021, 72, 1, 7.2500000000000000, 277, 1, 7.2500000000000000, 277, 1, 9154, 3117, '2011-05-05', '2016-06-19', 6, 2011, 2016, 551, 'long', 'low', 'medium'], ['Netflix', 'governator', 124.2000000000000000, 159, 75, 19.0365217391304348, 2189.2000000000000000, 3324, 1066, 4.1073170731707317, 263, 1, 24.8400000000000000, 316, 1, 24.8400000000000000, 316, 1, 10946, 4229, '2012-03-18', '2016-06-23', 5, 2012, 2016, 621, 'long', 'medium', 'medium'], ['gabrielemariotti', 'cardslib', 109.0000000000000000, 223, 3, 16.6840390879478827, 1707.3333333333333333, 3340, 19, 3.2812299807815503, 95, 1, 46.7142857142857143, 285, 1, 46.7142857142857143, 285, 1, 5122, 3940, '2013-09-20', '2015-05-12', 3, 2013, 2015, 327, 'long', 'medium', 'medium'], ['amlcurran', 'ShowcaseView', 66.4000000000000000, 141, 6, 8.6193548387096774, 534.4000000000000000, 1156, 74, 5.8984547461368653, 70, 1, 10.7096774193548387, 215, 1, 10.7096774193548387, 215, 1, 2672, 927, '2012-08-14', '2016-05-30', 5, 2012, 2016, 332, 'long', 'low', 'small'], ['johncarl81', 'parceler', 57.0000000000000000, 76, 41, 14.7177033492822967, 769.0000000000000000, 1151, 516, 2.4316205533596838, 31, 1, 45.6000000000000000, 217, 1, 45.6000000000000000, 217, 1, 3076, 1619, '2013-07-03', '2016-06-22', 4, 2013, 2016, 228, 'long', 'low', 'small'], ['mapstruct', 'mapstruct', 120.8000000000000000, 288, 7, 19.0373831775700935, 2037.0000000000000000, 4462, 201, 2.0357785328802718, 81, 1, 54.9090909090909091, 334, 1, 54.9090909090909091, 334, 1, 10185, 7885, '2012-05-28', '2016-06-15', 5, 2012, 2016, 604, 'long', 'medium', 'medium'], ['skylot', 'jadx', 120.0000000000000000, 208, 11, 19.6252631578947368, 2330.5000000000000000, 3915, 248, 2.4069197004905758, 197, 1, 43.6363636363636364, 436, 1, 43.6363636363636364, 436, 1, 9322, 6012, '2013-03-18', '2016-03-27', 4, 2013, 2016, 480, 'long', 'medium', 'medium'], ['Atmosphere', 'nettosphere', 67.2000000000000000, 118, 5, 9.0126182965299685, 571.4000000000000000, 1074, 10, 4.3685015290519878, 46, 1, 37.3333333333333333, 322, 1, 37.3333333333333333, 322, 1, 2857, 1112, '2012-02-09', '2016-04-11', 5, 2012, 2016, 336, 'long', 'low', 'small'], ['gridgain', 'yardstick', 106.5000000000000000, 208, 5, 6.3664921465968586, 608.0000000000000000, 1163, 53, 3.6516516516516517, 62, 1, 23.6666666666666667, 137, 1, 23.6666666666666667, 137, 1, 1216, 512, '2014-04-11', '2015-10-12', 2, 2014, 2015, 213, 'medium', 'medium', 'small'], ['arquillian', 'arquillian-core', 59.1250000000000000, 175, 6, 15.1986301369863014, 832.1250000000000000, 3421, 55, 2.0289545870161536, 110, 1, 36.3846153846153846, 420, 1, 36.3846153846153846, 420, 1, 6657, 5563, '2009-11-13', '2016-03-16', 8, 2009, 2016, 473, 'long', 'low', 'medium'], ['haifengl', 'smile', 79.0000000000000000, 121, 6, 18.4714285714285714, 1293.0000000000000000, 1918, 872, 1.8559808612440191, 24, 1, 19.7500000000000000, 155, 1, 19.7500000000000000, 155, 1, 3879, 3885, '2014-11-20', '2016-06-24', 3, 2014, 2016, 237, 'long', 'low', 'medium'], ['orfjackal', 'retrolambda', 68.7500000000000000, 133, 24, 9.9538461538461538, 647.0000000000000000, 1501, 212, 3.0591016548463357, 83, 1, 25.0000000000000000, 237, 1, 25.0000000000000000, 237, 1, 2588, 1111, '2013-07-20', '2016-04-30', 4, 2013, 2016, 275, 'long', 'low', 'small'], ['kevinsawicki', 'http-request', 54.6000000000000000, 108, 5, 6.7181467181467181, 348.0000000000000000, 752, 14, 2.5588235294117647, 50, 1, 39.0000000000000000, 267, 1, 39.0000000000000000, 267, 1, 1740, 726, '2011-10-21', '2015-01-21', 5, 2011, 2015, 273, 'long', 'low', 'small'], ['openzipkin', 'brave', 84.2500000000000000, 108, 56, 26.9758620689655172, 1955.7500000000000000, 3300, 1038, 4.2378114842903575, 83, 1, 14.6521739130434783, 225, 1, 14.6521739130434783, 225, 1, 7823, 4204, '2013-04-07', '2016-06-21', 4, 2013, 2016, 337, 'long', 'low', 'medium']]

size = "| ACRA             | acra            |          32 | medium
| arquillian       | arquillian-core |          49 | medium
| google           | blockly-android |           8 | small
| openzipkin       | brave           |          32 | medium
| gabrielemariotti | cardslib        |          13 | small
| square           | dagger          |          38 | medium
| deeplearning4j   | deeplearning4j  |          61 | medium
| facebook         | fresco          |          45 | medium
| Netflix          | governator      |          31 | medium
| greenrobot       | greenDAO        |           4 | small
| kevinsawicki     | http-request    |          14 | small
| koush            | ion             |          29 | small
| skylot           | jadx            |          11 | small
| mapstruct        | mapstruct       |          22 | small
| Atmosphere       | nettosphere     |          12 | small
| johncarl81       | parceler        |          12 | small
| orfjackal        | retrolambda     |          11 | small
| amlcurran        | ShowcaseView    |          39 | medium
| haifengl         | smile           |          14 | small
| perwendel        | spark           |          86 | medium
| apache           | storm           |         260 | large
| prestodb         | tempto          |          19 | small
| gridgain         | yardstick       |          12 | small"

def dev_size(people)

    if people < 30
        return "small"
    elsif people < 100 # & >=30
        return "medium"
    end
    # >= 100
    return "large"
end

devs = Hash.new
lines = Hash.new
size.each_line do |line|
    cols = line.split(/\|/).map do |col|
        col.strip
    end
    # To recalculate without manual categorizations
    #lines[cols[2]] = dev_size(cols[-1])
    devs[cols[2]] = cols[-2]
    lines[cols[2]] = cols[-1]
end

a = a.sort_by do |list|
    list[1].downcase
end

# TODO consider adding a sort. Either to group them as before or just alphabitically by project name

### EXPERIMENTS table tab:project_size_summary
=begin
puts "name & project length & project size & # devs & commit rate"
a.each do |project|
    puts "#{project[1]} & #{project[-3]} & #{project[-1]} & #{lines[project[1]]} & #{project[-2]}"
end
=end


### EXPERIMENTS table tab:project_summary

footnotes = Array.new
first = true
a.each do |project|

    #puts "#{project[0]} & #{project[1]}\\protect\\footnotemark & #{project[20]} & #{project[21]} & #{project[25]} & #{devs[project[1]]} \\\\"
    puts "#{project[0]} & #{project[1]} & #{project[20]} & #{project[21]} & #{project[25]} & #{devs[project[1]]} \\\\"

    counter = 1
    if first
        first = false
        counter = (a.size - 1) * -1
    end

    #footnotes << "\\addtocounter{footnote}{#{counter}}"
    #footnotes << "\\footnotetext{\\url{https://github.com/#{project[0]}/#{project[1]}}}"
end


puts "FOOTNOTES:"

footnotes.each do |note|
    puts note
end




### Experiments table tab:project_stats
=begin
a.each do |project|

    puts "#{project[1]} & #{project[19]} & #{project[18]} & #{project[2].round(2)} & #{project[5].round(2)} \\\\"
end
=end

### Experiments table tab:project_stats_2
=begin
a.each do |project|

    puts "#{project[1]} & #{project[6].round(2)} & #{project[9].round(2)} & #{project[12].round(2)} & #{project[3]} & #{project[4]} \\\\"
end
=end

### Experiments table tab:project_stats_3
=begin

a.each do |project|

    puts "#{project[1]} & #{project[7]} & #{project[8]} & #{project[10]} & #{project[13]} & #{project[14]} \\\\"
end
=end


### Experiments enumeration
=begin
a.each do |project|

    puts "\\item \\textbf{#{project[1]}}\\footnote{\\url{https://github.com/#{project[0]}/#{project[1]}}}"
end
=end
