After training, temporary files like events37537375696294525.tmp remain in the temporary directory.
AFAIK, the problem
TwoPassDataIndexer -> open reader in the FileEventStream -> reader remains open -> file.delete() does not work.
A possible solution might be - remove deleteOnExit() due unreliabilty and memory consumption, add explicit .close() call:
Left base folder: D:\Aliaksandr\Stage\NLP\parsers\OpenNLP\1.4.3\maxent-cvs\maxent.org
Right base folder: D:\Aliaksandr\Stage\NLP\parsers\OpenNLP\1.4.3\maxent-cvs\maxent
*** src\main\java\opennlp\model\FileEventStream.java 2009-10-02 14:13:50.000000000 +-0200
--- src\main\java\opennlp\model\FileEventStream.java 2009-01-23 00:23:33.000000000 +-0200
***************
*** 100,115 ****
sb.append(" "+context[ci]);
}
sb.append(System.getProperty("line.separator"));
return sb.toString();
}
- public void closeFile() throws IOException {
- reader.close();
- }
-
/**
* Trains and writes a model based on the events in the specified event file.
* the name of the model created is based on the event file name.
* @param args eventfile [iterations cuttoff]
* @throws IOException when the eventfile can not be read or the model file can not be written.
*/
--- 100,111 ----
*** src\main\java\opennlp\model\TwoPassDataIndexer.java 2009-10-02 14:13:11.000000000 +-0200
--- src\main\java\opennlp\model\TwoPassDataIndexer.java 2009-03-15 04:25:05.000000000 +-0200
***************
*** 71,92 ****
System.out.println("Indexing events using cutoff of " + cutoff + "\n");
System.out.print("\tComputing event counts... ");
try {
File tmp = File.createTempFile("events", null);
Writer osw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tmp),"UTF8"));
int numEvents = computeEventCounts(eventStream, osw, predicateIndex, cutoff);
System.out.println("done. " + numEvents + " events");
System.out.print("\tIndexing... ");
! FileEventStream fileEventStream = new FileEventStream(tmp);
! eventsToCompare = index(numEvents, fileEventStream, predicateIndex);
! fileEventStream.closeFile();
!
// done with predicates
predicateIndex = null;
tmp.delete();
System.out.println("done.");
if (sort) {
--- 71,90 ----
System.out.println("Indexing events using cutoff of " + cutoff + "\n");
System.out.print("\tComputing event counts... ");
try {
File tmp = File.createTempFile("events", null);
+ tmp.deleteOnExit();
Writer osw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tmp),"UTF8"));
int numEvents = computeEventCounts(eventStream, osw, predicateIndex, cutoff);
System.out.println("done. " + numEvents + " events");
System.out.print("\tIndexing... ");
! eventsToCompare = index(numEvents, new FileEventStream(tmp), predicateIndex);
// done with predicates
predicateIndex = null;
tmp.delete();
System.out.println("done.");
if (sort) {
It might be better introducing a bit more generic fix, like .close() method in an AbstractEventStream, so the resources the stream allocated during creation will be released explicitly upon .close() method call.