w2v-server.pl: show frequency ranks
diff --git a/w2v-server.pl b/w2v-server.pl
index e62c63c..d10325f 100644
--- a/w2v-server.pl
+++ b/w2v-server.pl
@@ -171,6 +171,7 @@
 		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]));
@@ -194,8 +195,12 @@
   <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
 	<script>
  $(function() {
-    $( document ).tooltip();
-  });
+    $( 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>
@@ -209,6 +214,12 @@
 	font-size: 9pt;
 	colour: #222222;
 }
+
+svg > .ui-tooltip-content {
+	font-size: 7pt;
+	colour: #222222;
+}
+
 svg {
 //  border: 1px solid #333;
   margin-right: 10px;
@@ -274,6 +285,9 @@
 	 
    g.append("a")
 		.attr("xlink:href", function(word) {return "/?word="+word;})
+	  .attr("title", function(d, i) {
+			return "rank: "+i +"  "+"freq. rank: "+data.ranks[i];
+		})
 		.append("text")
     .attr("text-anchor", "top")
     .attr("font-size", 12)
@@ -350,13 +364,14 @@
 	<div id="wrapper">
 		<table id="first">
 			<tr>
-				<th align="right">Pos.</th><th align="left">Word</th><th align="right">Cosine dist.</th>
+				<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; for my $list (@$lists) {
+			% 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">
@@ -370,6 +385,9 @@
 				<td align="right">
   				<%= sprintf("%.3f", $item->{dist}) %>
 				</td>
+				<td align="right">
+  				<%= $item->{rank} %>
+				</td>
 			</tr>
 			% }
 			% }
@@ -377,7 +395,7 @@
 		<script>
 		 % use Mojo::ByteStream 'b';
 		 $(window).load(function() {
-			 showMap(<%= b(Mojo::JSON::to_json({target => " $word ", words => \@words, vecs => \@vecs})); %>);
+			 showMap(<%= b(Mojo::JSON::to_json({target => " $word ", words => \@words, vecs => \@vecs, ranks => \@ranks})); %>);
 		 });
     </script>
 		% }