I have been quite this period trying to figure out a way to group visually messages that refers to the same keyword. After a couple of bad attempts I tried to visualize a polygon connecting the messages referring to the same keyword. Subsequently, I tried to find the centroids of the polygon using this nice formula. Then I decided to attach the keyword to this “center of gravity”. This seems to be simple but it was damn hard, as I had to find the good sequence to connect the points of the polygon to avoid self interceptions of the lines.
Anyway, there are still some flaws in the code but here is the first rendering to comment and destroy. All comments are welcome.