tnt.metrics
Class WordFreqKs

java.lang.Object
  extended by tnt.metrics.WordFreqKs
All Implemented Interfaces:
java.lang.Comparable<WordFreqKs>

public class WordFreqKs
extends java.lang.Object
implements java.lang.Comparable<WordFreqKs>

The WordFreqKs class encapsulates a word, its frequency in the corpus and the keystrokes required to type it. It also implements a compareTo method to sort such objects in ascending order according to keystrokes. Objects with equal keystrokes are sorted in decending order of frequency, then in ascending order by word.

Version:
1.0 - 01/2006
Author:
Steven J. Castellucci

Field Summary
 int freq
          The frequency of this word in the corpus.
 java.lang.String ks
          The keystrokes required to input this word.
 java.lang.String word
          A word in the corpus.
 
Constructor Summary
WordFreqKs(java.lang.String w, int f, java.lang.String k)
           
 
Method Summary
 int compareTo(WordFreqKs other)
          Sorts objects according to keystrokes.
static java.lang.String[] getFieldOrder()
          Returns the order of the fields returned by toStringArray().
 java.lang.String toString()
          Returns a tab-delimited String composed of word, frequency and keystrokes.
 java.lang.String[] toStringArray()
          Returns a String array composed of word, frequency and keystrokes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

word

public java.lang.String word
A word in the corpus.


freq

public int freq
The frequency of this word in the corpus.


ks

public java.lang.String ks
The keystrokes required to input this word.

Constructor Detail

WordFreqKs

public WordFreqKs(java.lang.String w,
                  int f,
                  java.lang.String k)
Method Detail

toString

public java.lang.String toString()
Returns a tab-delimited String composed of word, frequency and keystrokes.

Overrides:
toString in class java.lang.Object
Returns:
a tab-delimited String representing this object.

toStringArray

public java.lang.String[] toStringArray()
Returns a String array composed of word, frequency and keystrokes. Aids in displaying data in a table.

Returns:
a String[] representation of this object.

getFieldOrder

public static java.lang.String[] getFieldOrder()
Returns the order of the fields returned by toStringArray().

Returns:
a String[], representing field headings.

compareTo

public int compareTo(WordFreqKs other)
Sorts objects according to keystrokes. If they are equal, then compare frequencies and then alphabetical ordering. Returns a negative integer, zero or a positive integer if this object is less than, equal to or greater than the passed object.

Important: Changing the functionality of this method could affect the correctness of classes that use it!

Specified by:
compareTo in interface java.lang.Comparable<WordFreqKs>


Copyright © 2006 Steven Castellucci and Scott MacKenzie. All Rights Reserved.