I am a newbie to Java and I wish to run the library JGibbLDA
. I did as required by the document, enter the root directory of JGibbLDA-v.1.0
and input the command:
java -mx512M -cp bin:lib/args4j-2.0.6.jar jgibblda.LDA -est -alpha 0.5 -beta 0.1 -ntopics 100 -niters 1000 -savestep 100 -twords 20 -dfile models/data/data.txt
But an error occurs:
Read Dataset Error: /models/data/data.txt (No such file or directory)
java.io.FileNotFoundException: /models/data/data.txt (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at jgibblda.LDADataset.readDataSet(LDADataset.java:154)
at jgibblda.Model.initNewModel(Model.java:476)
at jgibblda.Estimator.init(Estimator.java:45)
at jgibblda.LDA.main(LDA.java:49)
Fail to read training data!
I don't know why there is a /
before the directory in the error log message. But the models/data/data.txt
really exist and I can enter models/data
at the root directory properly. The related code of the library is as below:
public static LDADataset readDataSet(BufferedReader reader, Dictionary dict){
try {
//read number of document
String line;
line = reader.readLine();
int M = Integer.parseInt(line);
System.out.println("NewM:" + M);
LDADataset data = new LDADataset(M, dict);
for (int i = 0; i < M; ++i){
line = reader.readLine();
data.setDoc(line, i);
}
return data;
}
catch (Exception e){
System.out.println("Read Dataset Error: " + e.getMessage());
e.printStackTrace();
return null;
}
}
I have also tried ../../models/data/data.txt
but also failed. Do you know how to solve this problem? Thank you in advance!
The program is looking for an absolute path and you are passing a relative path.
The error says:
/models/data/data.txt (No such file or directory)
^
|--- This is the root of your filesystem
Then you must pass the full path, try with full path (for example /home/youruser/project/models/data/data.txt):
java -mx512M -cp bin:lib/args4j-2.0.6.jar jgibblda.LDA -est -alpha 0.5 -beta 0.1 -ntopics 100 -niters 1000 -savestep 100 -twords 20 -dfile FULL_PATH