configurable output dir

This commit is contained in:
2021-07-26 20:54:13 -07:00
parent d9b542823b
commit 7caac67689
4 changed files with 16 additions and 16 deletions

View File

@ -51,6 +51,9 @@ when isMainModule:
paramStr(1)
else:
r"../BNC/2554/download/Texts/"
if not dirExists(basePath):
quit("Could not locate datafiles: directory " & basePath & " does not exist.")
var paths: seq[string]
for path in walkDirRec(basePath):
@ -76,6 +79,15 @@ when isMainModule:
counts.inc(word, count)
counts.sort()
save(counts, "dictionary.txt", "counts.txt")
let outPath =
if paramCount() > 1:
paramStr(2)
else:
"."
let
dPath = joinPath(outPath, "dictionary.txt")
cPath = joinPath(outPath, "counts.txt")
save(counts, dPath, cPath)
echo "Done. Finished in ", (getMonoTime() - start).inMilliseconds.float / 1000, " seconds."