All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class edu.vt.marian.common.Weight

java.lang.Object
   |
   +----edu.vt.marian.common.Weight

public class Weight
extends Object
implements Sortable
The weight of an object in some approximate context (e.g., match to a query).


Variable Index

 o bottomWt
 o EQUAL
the methods' return values.
 o HIGHER
 o LOWER
 o NOT_APPLY
 o NULL_STREAM
 o topWt
Public versions of the bounds for reasonable values.

Constructor Index

 o Weight(BufferedReader, Debug)
Create a Weight object from an input stream.
 o Weight(Debug)
Create an invalid Weight object.
 o Weight(double, Debug)
Create a Weight object based on a specified value.
 o Weight(int, Debug)
Create a Weight object based on a specified value.
 o Weight(Weight)
Create a Weight object based on another Weight object.

Method Index

 o accum(double)
"Add" a float between 0..1 to this object.
 o accum(Weight)
"Add" one Weight to another.
 o compare(Object)
 o compare(Weight)
Return the result of the comparision between this Weight object and the parameter Weight object.
 o getUnderlyingValue()
 o getValue()
Return the value of this Weight object.
 o isValid()
Tell whether or not this Weight object is valid.
 o readPacked(ByteArrayInputStream)
Read this out of compact storage in a byte array.
 o scale(double)
Scale one Weight by a real constant.
 o scale(Weight)
Scale one Weight by another.
 o set(Weight)
 o toStream(PrintWriter)
Print the content of this object to a specified stream.
 o writePacked(ByteArrayOutputStream)
Pack this into a byte array for compact storage.

Variables

 o topWt
 public static final Weight topWt
Public versions of the bounds for reasonable values.

 o bottomWt
 public static final Weight bottomWt
 o EQUAL
 public static final int EQUAL
the methods' return values.

 o HIGHER
 public static final int HIGHER
 o LOWER
 public static final int LOWER
 o NOT_APPLY
 public static final int NOT_APPLY
 o NULL_STREAM
 public static final int NULL_STREAM

Constructors

 o Weight
 public Weight(Debug debug)
Create an invalid Weight object.

Parameters:
debug - used for debugging
 o Weight
 public Weight(int i,
               Debug debug)
Create a Weight object based on a specified value.

Parameters:
i - the underlying value for this Weight object
debug - used for debugging
 o Weight
 public Weight(double f,
               Debug debug)
Create a Weight object based on a specified value.

Parameters:
f - the value of this Weight object;
debug - used for debugging
 o Weight
 public Weight(Weight w)
Create a Weight object based on another Weight object.

Parameters:
w - the Weight object to copy.
 o Weight
 public Weight(BufferedReader br,
               Debug debug)
Create a Weight object from an input stream.

Parameters:
br - the stream to read out this object
debug - used for debugging

Methods

 o isValid
 public boolean isValid()
Tell whether or not this Weight object is valid.

Returns:
true if this weight has a valid value set; false otherwise.
 o compare
 public int compare(Weight w)
Return the result of the comparision between this Weight object and the parameter Weight object.

Parameters:
w - the Weight object used to compared with this object
Returns:
EQUAL -- their values are equal; HIGHER -- the value of this object is higher than the parameter object; LOWER -- the value of this object is lower than the parameter object.
 o compare
 public int compare(Object obj)
 o scale
 public void scale(Weight w)
Scale one Weight by another.

Parameters:
w - the Weight object used to scale this object.

NOTE: We are using the integer values lower_limit..upper_limit to mimic the real number interval 0..1. As long as lower_limit == 0) we need only adjust to keep values proportionally under upper_limit, which we treat both as the top value and as multiplicative identity. We achieve this by multiplying the two "value" fields, then shifting the result right by 16 bits (effectively dividing by 2**16).

 o scale
 public void scale(double f)
Scale one Weight by a real constant.

Parameters:
f - the double precision value used to scale this object.
 o accum
 public void accum(Weight w)
"Add" one Weight to another.

Parameters:
w - the Weight object to be accumulated into this object.
 o accum
 public void accum(double f)
"Add" a float between 0..1 to this object.

Parameters:
f - the double precision value to be accumulated into this object.
 o getValue
 public double getValue()
Return the value of this Weight object.

Returns:
the value of this Weight object as a double.
 o getUnderlyingValue
 public int getUnderlyingValue()
 o set
 public void set(Weight w)
 o writePacked
 public int writePacked(ByteArrayOutputStream bos)
Pack this into a byte array for compact storage.

Parameters:
bos - a ByteArrayOutputStream into which to pack this.
Returns:
OK -- all jake; NULL_STREAM -- could not write.
 o readPacked
 public int readPacked(ByteArrayInputStream bis)
Read this out of compact storage in a byte array.

Parameters:
bis - a ByteArrayInputStream from which to unpack this.
Returns:
OK -- all jake; NULL_STREAM -- could not read.
 o toStream
 public int toStream(PrintWriter pw)
Print the content of this object to a specified stream.

Parameters:
pw - the stream to write this object
Returns:
OK -- the object has been written to the stream correctly; NULL_STREAM -- the parameter stream is null

All Packages  Class Hierarchy  This Package  Previous  Next  Index