at.tuwien.ifs.somtoolbox.output.labeling
Class UnitWords

java.lang.Object
  extended by at.tuwien.ifs.somtoolbox.output.labeling.UnitWords

public class UnitWords
extends Object

This class is used for saving the word frequencies of word cocurrences. It also calculates the words' relative frequency

Version:
$Id: UnitWords.java 4185 2011-03-01 14:18:52Z mayer $
Author:
Hauke Schuldt, Alois Wollersberger

Field Summary
private  double numberOfWords
           
private  boolean recalcNecessary
           
private  Hashtable<String,Double> wordFreq
           
private  int x
           
private  int y
           
private  int z
           
 
Constructor Summary
UnitWords(int x, int y, int z)
           
 
Method Summary
 void addWord(String word)
          Adds a word with frequency=1
 void addWord(String word, double frequency)
          Adds a word with its frequency.
 double getAbsoluteFrequency(String word)
          Calculates the relative frequency of a word in a unit
 double getNumberOfWords()
           
 double getRelativeFrequency(String word)
          Calculates the relative frequency of a word in a unit
 Set<String> getWordSet()
          Returns a Set which contains all words of this unit
 int getX()
           
 int getY()
           
 int getZ()
           
private  void recalcNumberOfWords()
          Calculates the total number of words
 void setNumberOfWords(double numberOfWords)
           
 void setX(int x)
           
 void setY(int y)
           
 void setZ(int z)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

private int x

y

private int y

z

private int z

numberOfWords

private double numberOfWords

recalcNecessary

private boolean recalcNecessary

wordFreq

private Hashtable<String,Double> wordFreq
Constructor Detail

UnitWords

public UnitWords(int x,
                 int y,
                 int z)
Parameters:
x - Position of the unit on the x-axis
y - Position of the unit on the y-axis
z - Position of the unit on the z-axis
Method Detail

setX

public void setX(int x)
Parameters:
x - The x to set.

getX

public int getX()
Returns:
Returns the x.

setY

public void setY(int y)
Parameters:
y - The y to set.

getY

public int getY()
Returns:
Returns the y.

setZ

public void setZ(int z)
Parameters:
z - The z to set.

getZ

public int getZ()
Returns:
Returns the z.

setNumberOfWords

public void setNumberOfWords(double numberOfWords)
Parameters:
numberOfWords - The numberOfWords to set.

getNumberOfWords

public double getNumberOfWords()
Returns:
Returns the numberOfWords.

getAbsoluteFrequency

public double getAbsoluteFrequency(String word)
Calculates the relative frequency of a word in a unit

Returns:
Returns the relative frequency of the word

getRelativeFrequency

public double getRelativeFrequency(String word)
Calculates the relative frequency of a word in a unit

Returns:
Returns the relative frequency of the word

addWord

public void addWord(String word)
Adds a word with frequency=1

Parameters:
word - the word to add
See Also:
addWord(String word, double frequency)

addWord

public void addWord(String word,
                    double frequency)
Adds a word with its frequency. The frequency will be added to the existing frequency if the word already exists.

Parameters:
word - the word to add
frequency - of the occurrence of the word

recalcNumberOfWords

private void recalcNumberOfWords()
Calculates the total number of words


getWordSet

public Set<String> getWordSet()
Returns a Set which contains all words of this unit

Returns:
the set of words