#!/usr/local/bin/perl
use Inline C;
use Mojolicious::Lite;
use Mojo::JSON qw(decode_json encode_json to_json);
use Encode qw(decode encode);
use Mojo::Server::Daemon;

print STDERR $ARGV[0];
# -cbow 1 -size 200 -window 8 -negative 25 -hs 0 -sample 1e-4 -threads 40 -binary 1 -iter 15
init_net("vectors15.bin");

get '/' => sub {
  my $c    = shift;
	my $word=$c->param('word');
  my $no_nbs=$c->param('n') || 100;
  my $no_iterations=$c->param('N') || 2000;
  my $perplexity=$c->param('perplexity') || 25;
  my $epsilon=$c->param('epsilon') || 5;
  
	my @lists;
	if(defined($word) && $word !~ /^\s*$/) {
		$c->inactivity_timeout(300);
		$word =~ s/\s+/ /g;
    for my $w (split(' *\| *', $word)) {
			$c->app->log->debug('Looking for neighbours of '.$w);
			push(@lists, get_neighbours(encode("iso-8859-1", $w), $no_nbs));
		}
	}
	$word =~ s/ *\| */ | /g;
  $c->render(template=>"index", word=>$word, no_nbs=>$no_nbs, no_iterations => $no_iterations, epsilon=> $epsilon, perplexity=> $perplexity, lists=> \@lists);
};

app->start;

exit;

__END__

__C__
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <malloc.h>
#include <stdlib.h>    //strlen
#include <sys/mman.h>
#include <pthread.h>

#define max_size 2000
#define max_w 50
#define MAX_NEIGHBOURS 1000
#define MAX_WORDS -1
#define MAX_THREADS 100

//the thread function
void *connection_handler(void *);

typedef struct {
	long long *index;
	float *dist;
	unsigned int length;
} knn;


typedef struct {
	char *token;
	int N;
	unsigned long from;
	unsigned long upto;
} knnpars;

float *M;
char *vocab;
long long words, size;
int num_threads=20;

int init_net(char *file_name) {
  FILE *f, *binvecs, *binwords;
	int binwords_fd, binvecs_fd;
	long long a, b, c, d, cn;
	float len;

	char binvecs_fname[256], binwords_fname[256];
	strcpy(binwords_fname, file_name);
	strcat(binwords_fname, ".words");
	strcpy(binvecs_fname, file_name);
	strcat(binvecs_fname, ".vecs");

  f = fopen(file_name, "rb");
  if (f == NULL) {
    printf("Input file %s not found\n", file_name);
    return -1;
  }
  fscanf(f, "%lld", &words);
	if(MAX_WORDS > 0 && words > MAX_WORDS) words = MAX_WORDS;
  fscanf(f, "%lld", &size);
	if( (binvecs_fd = open(binvecs_fname, O_RDONLY)) >= 0 && (binwords_fd = open(binwords_fname, O_RDONLY)) >= 0) {
		M = mmap(0, sizeof(float) * (long long)words * (long long)size, PROT_READ, MAP_SHARED, binvecs_fd, 0);
		vocab = mmap(0,  sizeof(char) * (long long)words * max_w, PROT_READ, MAP_SHARED, binwords_fd, 0);
    if (M == MAP_FAILED || vocab == MAP_FAILED) {
			close(binvecs_fd);
			close(binwords_fd);
			fprintf(stderr, "Cannot mmap %s or %s\n", binwords_fname, binvecs_fname);
			exit(-1);
    }
	} else {
		vocab = (char *)malloc((long long)words * max_w * sizeof(char));
		M = (float *)malloc((long long)words * (long long)size * sizeof(float));
		if (M == NULL) {
			printf("Cannot allocate memory: %lld MB    %lld  %lld\n", (long long)words * size * sizeof(float) / 1048576, words, size);
			return -1;
		}
		for (b = 0; b < words; b++) {
			a = 0;
			while (1) {
				vocab[b * max_w + a] = fgetc(f);
				if (feof(f) || (vocab[b * max_w + a] == ' ')) break;
				if ((a < max_w) && (vocab[b * max_w + a] != '\n')) a++;
			}
			vocab[b * max_w + a] = 0;
			fread(&M[b * size], sizeof(float), size, f);
			len = 0;
			for (a = 0; a < size; a++) len += M[a + b * size] * M[a + b * size];
			len = sqrt(len);
			for (a = 0; a < size; a++) M[a + b * size] /= len;
		}
		if( (binvecs = fopen(binvecs_fname, "wb")) != NULL && (binwords = fopen(binwords_fname, "wb")) != NULL) {
			fwrite(M, sizeof(float), (long long)words * (long long)size, binvecs);
			fclose(binvecs);
			fwrite(vocab, sizeof(char), (long long)words * max_w, binwords);
			fclose(binwords);
		}
	}
  fclose(f);
	return 0;
}


void *_get_neighbours(knnpars *pars) {
	char *st1 = pars->token;
	int N = pars->N;
	unsigned long from = pars -> from;
	unsigned long upto = pars -> upto;
	char file_name[max_size], st[100][max_size];
	float dist, len, *bestd, vec[max_size];
	long long a, b, c, d, cn, bi[100], *besti;
	char ch;
	knn *nbs = NULL;

	besti = malloc(N * sizeof(long long));
	bestd = malloc(N * sizeof(float));

	float worstbest=-1;

	for (a = 0; a < N; a++) bestd[a] = 0;
	a = 0;
	cn = 0;
	b = 0;
	c = 0;
	while (1) {
		st[cn][b] = st1[c];
		b++;
		c++;
		st[cn][b] = 0;
		if (st1[c] == 0) break;
		if (st1[c] == ' ') {
			cn++;
			b = 0;
			c++;
		}
	}
	cn++;
	for (a = 0; a < cn; a++) {
		for (b = 0; b < words; b++) if (!strcmp(&vocab[b * max_w], st[a])) break;
		if (b == words) b = -1;
		bi[a] = b;
		fprintf(stderr, "Word: \"%s\"  Position in vocabulary: %lld\n", st[a], bi[a]);
		if (b == -1) {
			fprintf(stderr, "Out of dictionary word!\n");
			cn--;
			break;
		}
	}
	if (b == -1) {
    N = 0;
	  goto end;
  }
	for (a = 0; a < size; a++) vec[a] = 0;
	for (b = 0; b < cn; b++) {
		if (bi[b] == -1) continue;
		for (a = 0; a < size; a++) vec[a] += M[a + bi[b] * size];
	}
	len = 0;
	for (a = 0; a < size; a++) len += vec[a] * vec[a];
	len = sqrt(len);
	for (a = 0; a < size; a++) vec[a] /= len;
	for (a = 0; a < N; a++) bestd[a] = -1;
	for (c = from; c < upto; c++) {
		a = 0;
// do not skip taget word
//		for (b = 0; b < cn; b++) if (bi[b] == c) a = 1;
//		if (a == 1) continue;
		dist = 0;
		for (a = 0; a < size; a++) dist += vec[a] * M[a + c * size];
		if(dist > worstbest) {
			for (a = 0; a < N; a++) {
				if (dist > bestd[a]) {
					for (d = N - 1; d > a; d--) {
						bestd[d] = bestd[d - 1];
						besti[d] = besti[d - 1];
					}
					bestd[a] = dist;
					besti[a] = c;
					break;
				}
			}
			worstbest = bestd[N-1];
		}
	}

	nbs = malloc(sizeof(knn));
	nbs->index = besti;
	nbs->dist = bestd;
	nbs->length = N;
end:
	pthread_exit(nbs);
}

SV *get_neighbours(char *st1, int N) {
	float bestd[MAX_NEIGHBOURS], vec[max_size];
	long long besti[MAX_NEIGHBOURS], a, b, c, d, slice;
	char *bestw[MAX_NEIGHBOURS];
	knn *nbs[MAX_THREADS];
	knnpars pars[MAX_THREADS];
  pthread_t *pt = (pthread_t *)malloc(num_threads * sizeof(pthread_t));
	AV* array = newAV();

  if(N>MAX_NEIGHBOURS) N=MAX_NEIGHBOURS;
	
	slice = words / num_threads;

	for(a=0; a < num_threads; a++) {
		pars[a].token = st1;
		pars[a].N = N;
		pars[a].from = a*slice;
		pars[a].upto = ((a+1)*slice > words? words:(a+1)*slice);
		pthread_create(&pt[a], NULL, _get_neighbours, (void *) &pars[a]);
	}
  for (a = 0; a < num_threads; a++) pthread_join(pt[a], &nbs[a]);

	if(!nbs[0])
		goto end;

	for(b=0; b < N; b++) {
		besti[b] = nbs[0]->index[b];
		bestd[b] = nbs[0]->dist[b];
	}

	for(a=1; a < num_threads; a++) {
		for(b=0; b < N; b++) {
			for(c=0; c < N; c++) {
				if(nbs[a]->dist[b] > bestd[c]) {
					for(d=N-1; d>c; d--) {
						bestd[d] = bestd[d-1];
						besti[d] = besti[d-1];
					}
					besti[c] = nbs[a]->index[b];
					bestd[c] = nbs[a]->dist[b];
					break;
				}
			}
		}
	}

	if(nbs) {
		for (a = 0; a < N; a++) {
			bestw[a] = (char *)malloc(max_size * sizeof(char));
		}
		for (a = 0; a < N; a++) {
			strcpy(bestw[a], &vocab[besti[a] * max_w]);
			HV* hash = newHV();
			hv_store(hash, "word", strlen("word"), newSVpvf(bestw[a], 0), 0);
			hv_store(hash, "dist", strlen("dist"), newSVnv(bestd[a]), 0);
			hv_store(hash, "rank", strlen("rank"), newSVuv(besti[a]), 0);
			AV *vector = newAV();
			for (b = 0; b < size; b++) {
				av_push(vector, newSVnv(M[b + besti[a] * size]));
			}
			hv_store(hash, "vector", strlen("vector"), newRV_noinc((SV*)vector), 0);
			av_push(array, newRV_noinc((SV*)hash));
		}
	}
end:
	return newRV_noinc((SV*)array);
}

__DATA__

@@ index.html.ep
<!DOCTYPE html>
<html>
<head>
	<title>DeReKo-Word-Vector-Distances</title>
	<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
	<script src="http://code.jquery.com/jquery-latest.min.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
	<script>
 $(function() {
    $( document ).tooltip({
			content: function() {
				return $(this).attr('title');
			}}
		)
	 })
  </script>
	<script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>
	<script src="http://klinux10/word2vec/tsne.js"></script>
	<script src="http://klinux10/word2vec/labeler.js"></script>
<style>
body, input {
	font-family: Arial, sans-serif;
	font-size: 11pt;
}

.ui-tooltip-content {
	font-size: 9pt;
	colour: #222222;
}

svg > .ui-tooltip-content {
	font-size: 8pt;
	colour: #222222;
}

svg {
    margin-right: 10px;
    margin-bottom: 10px;
}
#wrapper {
    width: 100%;
//   border: 1px solid red; 
    overflow: hidden; /* will contain if #first is longer than #second */
}
#first {
    margin-right: 20px;
    float: left;
 //    border: 1px solid green;
}
#second {
    border: 1px solid #333;
    overflow: hidden; /* if you don't want #second to wrap below #first */
}
#cost {
	  font-size: 8pt;
	  color: #222222;
    margin-top: 4px;
}
</style>
<script>

var opt = {epsilon: <%= $epsilon %>, perplexity: <%= $perplexity %>},
		mapWidth = 800, // width map
		mapHeight = 800,
		jitterRadius = 7;

var T = new tsnejs.tSNE(opt); // create a tSNE instance

var Y;

var data;
var labeler;


function applyJitter() {
  svg.selectAll('.u')
    .data(labels)
    .transition()
    .duration(50)
    .attr("transform", function(d, i) {
      T.Y[i][0] = (d.x - mapWidth/2 - tx)/ss/20;
      T.Y[i][1] = (d.y - mapHeight/2 - ty)/ss/20;
      return "translate(" +
        (d.x) + "," +
        (d.y) + ")";
    });
}
    
function updateEmbedding() {
  var Y = T.getSolution();
  svg.selectAll('.u')
     .data(data.words)
     .attr("transform", function(d, i) { 
			 return "translate(" +
         ((Y[i][0]*20*ss + tx) + mapWidth/2) + "," +
         ((Y[i][1]*20*ss + ty) + mapHeight/2) + ")"; });
}

var svg;
var labels = [];
var anchor_array = [];
var text;

function drawEmbedding() {
  $("#embed").empty();
  var div = d3.select("#embed");
	
  // get min and max in each column of Y
  var Y = T.Y;
  
  svg = div.append("svg") // svg is global
					 .attr("width", mapWidth)
					 .attr("height", mapHeight);
	
  var g = svg.selectAll(".b")
						 .data(data.words)
						 .enter().append("g")
						 .attr("class", "u");
	
  g.append("a")
	 .attr("xlink:href", function(word) {return "/?word="+word;})
	 .attr("title", function(d, i) {
		 return "rank: "+i +"  "+"freq. rank: "+data.ranks[i].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
	 })
		.append("text")
   .attr("text-anchor", "top")
   .attr("font-size", 12)
   .attr("fill", function(d) {
			if(data.target.indexOf(" "+d+" ") >= 0) {
				return "red";
			} else {
				return "#333"
			}
	 })
   .text(function(d) { return d; });
	
  var zoomListener = d3.behavior.zoom()
											 .scaleExtent([0.1, 10])
											 .center([0,0])
											 .on("zoom", zoomHandler);
  zoomListener(svg);
}

var tx=0, ty=0;
var ss=1;
var iter_id=-1;

function zoomHandler() {
  tx = d3.event.translate[0];
  ty = d3.event.translate[1];
  ss = d3.event.scale;
  updateEmbedding();
}

var stepnum = 0;

function stopStep() {
  clearInterval(iter_id);
	text = svg.selectAll("text");
	
  // jitter function needs different data and co-ordinate representation
	labels = d3.range(data.words.length).map(function(i) {
    var x = (T.Y[i][0]*20*ss + tx) + mapWidth/2;
    var y = (T.Y[i][1]*20*ss + ty) + mapHeight/2;
		anchor_array.push({x: x, y: y, r: jitterRadius});
		return {
      x: x,
      y: y,
			name: data.words[i]
		};
	});
  
  // get the actual label bounding boxes for the jitter function
	var index = 0;
	text.each(function() {
		labels[index].width = this.getBBox().width;
		labels[index].height = this.getBBox().height;
		index += 1;
	});

	 
//	 setTimeout(updateEmbedding, 1);
//	 setTimeout(
	labeler =	 d3.labeler()
			         .label(labels)
			         .anchor(anchor_array)
			         .width(mapWidth)
			         .height(mapHeight)
			         .update(applyJitter);
  //         .start(1000);

  iter_id = setInterval(jitterStep, 1);
}

var jitter_i=0;

function jitterStep() {
  if(jitter_i++ > 100) {
    clearInterval(iter_id);
  } else {
		labeler.start2(10);
	  applyJitter();
  }
}

var last_cost=1000;

function step() {
  var i = T.iter;
  
  if(i > <%= $no_iterations %>) {
		stopStep();
  } else {
    var cost = Math.round(T.step() * 100000) / 100000; // do a few steps
    $("#cost").html("tsne iteration " + i + ", cost: " + cost.toFixed(5));
    if(i % 250 == 0 && cost >= last_cost) {
		  stopStep();
    } else {
      last_cost = cost;
      updateEmbedding();
    }
  }
}

function showMap(j) {
	data=j;
  T.iter=0;
  T.initDataRaw(data.vecs); // init embedding
  drawEmbedding(); // draw initial embedding
	
	if(iter_id >= 0) {
		clearInterval(iter_id);
	}
  //T.debugGrad();
  iter_id = setInterval(step, 1);
  //step();
}
 
</script>
</head>
<body>
	<form action="<%=url_for('/')->to_abs%>" method="GET">
		word(s): 
    <input type="text" name="word" size="20"  value="<%= $word %>" title="When looking for multiple words use spaces as separators to search around the average vector and | as separator to get the neighbours for each word."> 
		max. neighbours: <input type="text" size="8" name="n" value="<%= $no_nbs %>">
		iterations: <input type="text" name="N" size="8" value="<%= $no_iterations %>">
		<input type="submit" value="Show">
	</form>
	<br>
	% if($lists) {
	<div id="wrapper">
		<table id="first">
			<tr>
				<th align="right">Pos.</th><th align="left">Word</th><th align="right">Cosine dist.</th><th>Freq. rank</th>
			</tr>
			% my $j=0; my @words; my @vecs; my @ranks; for my $list (@$lists) {
			% my $i=1; for my $item (@$list) {
			% if(!grep{$_ eq $item->{word}} @words) {
      %   push @vecs, $item->{vector};
			%   push @words, $item->{word};
			%   push @ranks, $item->{rank};
      % }
			<tr>
				<td align="right">
  				<%= $i++ %>.
				</td>
				<td>
  				<a href="/?word=<%= $item->{word} %>">
						<%= $item->{word} %>
					</a>
				</td>
				<td align="right">
  				<%= sprintf("%.3f", $item->{dist}) %>
				</td>
				<td align="right">
  				<%= $item->{rank} %>
				</td>
			</tr>
			% }
			% }
		</table>
		<script>
		 % use Mojo::ByteStream 'b';
		 $(window).load(function() {
			 showMap(<%= b(Mojo::JSON::to_json({target => " $word ", words => \@words, vecs => \@vecs, ranks => \@ranks})); %>);
		 });
    </script>
		% }
		<div id="second" style="width:800px; height:800px; font-family: arial;">
			<div id="embed">
			</div>
		</div>
    <div id="cost"></div>
  </div>
	<p>
		Word vector model based on  DeReKo-2015-II. Trained with <a href="https://code.google.com/p/word2vec/">word2vec</a> using the following parameters:</p>
  <pre>
-cbow 1 -size 300 -window 7 -negative 5 -hs 0 -sample 1e-5 -threads 44 -binary 1 -iter 5
	</pre>
	</p>
</body>
</html>

