public class ExactlySampleTextFile extends SampleTextFile
Usage:
java edu.northwestern.at.morphadorner.tools.sampletextfile.ExactlySampleTextFile input.txt output.txt samplecount
input.txt -- input text file to be sampled.
output.txt -- output text file.
samplecount -- Size of random sample to extract. Must be positive integer.
The output file is a text file containing the sampled text lines from the input file. Both the input and the output must be utf-8 encoded. The output lines are appended to any existing lines in the output file.
Modifier and Type | Field and Description |
---|---|
protected int |
sampleCount
Count of lines left to sample.
|
protected int |
totalCount
Count of lines left in input file.
|
inputFileName, outputFileName, sample
Constructor and Description |
---|
ExactlySampleTextFile(java.lang.String inputFileName,
java.lang.String outputFileName,
int sample)
Copy a text file to another while sampling the input lines.
|
Modifier and Type | Method and Description |
---|---|
static void |
help()
Help text.
|
protected boolean |
lineSelected(java.lang.String inputLine)
Check if line should be selected.
|
static void |
main(java.lang.String[] args)
Main program.
|
void |
sample()
Perform the sampling.
|
boolean |
samplingDone()
Determine if sampling done.
|
protected void |
setupSampling()
Setup sampling.
|
protected int totalCount
protected int sampleCount
public ExactlySampleTextFile(java.lang.String inputFileName, java.lang.String outputFileName, int sample)
inputFileName
- Input file name.outputFileName
- Output file name.sample
- Sample count, percentage, etc.public static void main(java.lang.String[] args)
args
- Program parameters.public static void help()
protected void setupSampling()
setupSampling
in class SampleTextFile
public void sample()
sample
in class SampleTextFile
protected boolean lineSelected(java.lang.String inputLine)
lineSelected
in class SampleTextFile
inputLine
- The input line.Subclasses must override this method.
public boolean samplingDone()
samplingDone
in class SampleTextFile