-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added training directories combiner, updated runexps.
- Loading branch information
Mike Speriosu
committed
Jun 27, 2013
1 parent
40edc02
commit baff312
Showing
2 changed files
with
97 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/scala/opennlp/fieldspring/tr/app/TrainingDirectoriesCombiner.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package opennlp.fieldspring.tr.app | ||
|
||
import java.io._ | ||
|
||
object TrainingDirectoriesCombiner extends App { | ||
val inDir1 = new File(args(0)) | ||
val inDir2 = new File(args(1)) | ||
val outDir = new File(args(2)) | ||
|
||
if(!outDir.exists) | ||
outDir.mkdir | ||
|
||
// First clear the source directory: | ||
for(file <- outDir.listFiles) | ||
file.delete | ||
|
||
lineByLineCopy(inDir1, outDir) | ||
lineByLineCopy(inDir2, outDir) | ||
|
||
def lineByLineCopy(inDir:File, outDir:File) { | ||
for(file <- inDir.listFiles.filter(_.getName.endsWith(".txt"))) { | ||
val in = new BufferedReader(new FileReader(file)) | ||
val out = new BufferedWriter(new FileWriter(outDir.getCanonicalPath+"/"+file.getName, true)) | ||
println(inDir.getCanonicalPath+"/"+file.getName+" >> "+outDir.getCanonicalPath+"/"+file.getName) | ||
var line = "i" | ||
while(line != null) { | ||
try { | ||
line = in.readLine | ||
} catch { | ||
case e: java.nio.charset.MalformedInputException => line = "E" | ||
} | ||
if(line != null && line.size > 1) | ||
out.write(line+"\n") | ||
} | ||
out.close | ||
in.close | ||
} | ||
} | ||
} |