WordRank

33 views
Skip to first unread message

Nathan Hughes

unread,
Nov 26, 2014, 8:44:45 AM11/26/14
to word...@googlegroups.com
Hopefully a quick easy query

Where 2 words have identical weight, how is rank decided? I can see any pattern.


Many Thanks

Dan Bernier

unread,
Nov 26, 2014, 9:15:28 AM11/26/14
to word...@googlegroups.com
I had to look through the source to figure it out, but the answer is, it's arbitrary: it's decided by java internals.

If you look at https://github.com/danbernier/WordCram/blob/master/src/wordcram/WordCram.java#L786, you can see where it uses the WordSorterAndScaler to sort and scale the words ("scale," in this case, meaning to normalize the weights to 0..1).

https://github.com/danbernier/WordCram/blob/master/src/wordcram/WordSorterAndScaler.java#L13 shows that it sorts them via Array.sort(), relying on Word's default sorting criteria.

Finally, https://github.com/danbernier/WordCram/blob/master/src/wordcram/Word.java#L305 shows that it's strictly by weight - so words of equal weight are considered equal. This means the specifics are handled internally.

Just curious, what's your situation? Are these equal-weight words "heavy," or "light?"

Nathan Hughes

unread,
Nov 26, 2014, 9:46:37 AM11/26/14
to word...@googlegroups.com
Hi

Yeah that was the point I got to as well.

What I'm trying to do is colour the top 5 words specific colours. I'm using this

class First5 implements WordColorer {
  int callCount = 0;

  public color colorFor(Word word) {
    callCount++;
    colorMode(RGB, 255, 255, 255);
    if (callCount == 1) {
      return color(2,27,65);
    } 
    else if (callCount == 2) {
     return color(0,53,173);
    } 
    else if (callCount == 3) {
     return color(0,163,224);
    } 
    else if (callCount == 4) {
     return color(209,216,227);
    } 
    else if (callCount == 5) {
     return color(204,51,51);
    } 
    else {
      return color(48,88,175);
    }
  }
}

Now while its possible to adapt this to colour words with the same weight the same way this could lead to dull wordclouds. So I just wanted to match the rank assigned by the array to my top 5 list so I could keep the colour list for the first 5 words, it doesn't seem to be byweight then by alphabetical or even byweight then by length, or even by the order the words are in the data file, it almost looks random.
Reply all
Reply to author
Forward
0 new messages