public class DigramHist extends Object implements Streamable
The file dfreq.dat in the ElsieFour Library distribution contains a streamed DigramHist object that is a histogram of English letter digrams from the 25 most popular novels from Project Gutenberg.
Constructor and Description |
---|
DigramHist()
Construct a new digram histogram object.
|
Modifier and Type | Method and Description |
---|---|
static int |
bucketOf(int c)
Convert the given character to a bucket index.
|
long |
count(int i,
int j)
Returns the count for the given digram in this histogram.
|
double |
freq(int i,
int j)
Returns the frequency of the given digram among all digrams in this
histogram.
|
void |
increment(int i,
int j)
Increment the count for the given digram in this histogram.
|
static char |
letterOf(int i)
Convert the given bucket index to a letter.
|
void |
readIn(InStream in)
Read this histogram from the given in stream.
|
double |
rowFreq(int i,
int j)
Returns the frequency of the given digram among all digrams with the
given first letter in this histogram.
|
long |
rowTotal(int i)
Returns the total count for all digrams with the given first letter in
this histogram.
|
long |
total()
Returns the total count for all digrams in this histogram.
|
void |
writeOut(OutStream out)
Write this histogram to the given out stream.
|
public void increment(int i, int j)
i
- Bucket index of first letter (0 .. 25).j
- Bucket index of second letter (0 .. 25).bucketOf(int)
public long count(int i, int j)
i
- Bucket index of first letter (0 .. 25).j
- Bucket index of second letter (0 .. 25).bucketOf(int)
public long rowTotal(int i)
i
- Bucket index of first letter (0 .. 25).bucketOf(int)
public long total()
public double rowFreq(int i, int j)
i
- Bucket index of first letter (0 .. 25).j
- Bucket index of second letter (0 .. 25).bucketOf(int)
public double freq(int i, int j)
i
- Bucket index of first letter (0 .. 25).j
- Bucket index of second letter (0 .. 25).bucketOf(int)
public static int bucketOf(int c)
c
- Character.public static char letterOf(int i)
i
- Bucket index.public void writeOut(OutStream out) throws IOException
writeOut
in interface Streamable
out
- Out stream.IOException
- Thrown if an I/O error occurred.public void readIn(InStream in) throws IOException
readIn
in interface Streamable
in
- In stream.IOException
- Thrown if an I/O error occurred.Copyright © 2017 by Alan Kaminsky. All rights reserved. Send comments to ark@cs.rit.edu.