w2v-server: introduce position heats for collocators
diff --git a/w2v-server.pl b/w2v-server.pl
index 605db6c..35b0295 100755
--- a/w2v-server.pl
+++ b/w2v-server.pl
@@ -194,6 +194,7 @@
 	float activation_sum;
 	float conorm;
 	float max_activation;
+  float heat[16];
 } collocator;
 
 typedef struct {
@@ -793,6 +794,7 @@
 			best[b].conorm = 0.0;
 			best[b].probability = 0.0;
 			best[b].cprobability = syn_nbs[0]->best[b].cprobability;
+      memset(best[b].heat, 0, sizeof(float) * 16);
     }
 		
 		float best_window_sum[MAX_NEIGHBOURS];
@@ -847,6 +849,8 @@
 									word_activation_sum += syn_nbs[a]->best[b].activation;
                   if(syn_nbs[a]->best[b].activation > best[i].max_activation)
 										best[i].max_activation = syn_nbs[a]->best[b].activation;
+                  if(syn_nbs[a]->best[b].cprobability > best[i].heat[wpos])
+										best[i].heat[wpos] = syn_nbs[a]->best[b].cprobability;
 								}
 						}
 					}
@@ -939,9 +943,10 @@
 					continue;
 			}
 */
-			chosen[i++]=&vocab[c * max_w];
+			chosen[i++]=c;
       HV* hash = newHV();
       SV* word = newSVpvf(&vocab[best[a].wordi * max_w], 0);
+      AV* heat = newAV();
       if(latin_enc == 0) SvUTF8_on(word);
       hv_store(hash, "word", strlen("word"), word , 0);
       hv_store(hash, "rank", strlen("rank"), newSVuv(best[a].wordi), 0);
@@ -951,6 +956,9 @@
       hv_store(hash, "max", strlen("max"), newSVnv(best[a].max_activation), 0); // newSVnv(target_sums[best[a].wordi]), 0);
       hv_store(hash, "overall", strlen("overall"), newSVnv(best[a].activation_sum/total_activation), 0); // newSVnv(target_sums[best[a].wordi]), 0);
       hv_store(hash, "pos", strlen("pos"), newSVnv(best[a].position), 0);
+      best[a].heat[5]=0;
+      for(i=10; i >= 0; i--) av_push(heat, newSVnv(best[a].heat[i]));
+      hv_store(hash, "heat", strlen("heat"), newRV_noinc((SV*)heat), 0);
       av_push(array, newRV_noinc((SV*)hash));
     }
     hv_store(result, "syntagmatic", strlen("syntagmatic"), newRV_noinc((SV*)array), 0);