configurable output dir
This commit is contained in:
parent
d9b542823b
commit
7caac67689
@ -26,25 +26,13 @@ proc runCmd(command: string, input = "", cache = ""): string =
|
|||||||
quit(exitCode)
|
quit(exitCode)
|
||||||
result = output
|
result = output
|
||||||
|
|
||||||
proc pathExists(filename: string): bool =
|
|
||||||
let (output, code) = gorgeEx("ls " & filename)
|
|
||||||
return code == 0
|
|
||||||
|
|
||||||
|
|
||||||
task(dictionary, "Generate dictionary from BNC XML files"):
|
task(dictionary, "Generate dictionary from BNC XML files"):
|
||||||
if not pathExists("BNC"):
|
|
||||||
quit("Cannot build dictionary: BNC data files not found.", 1)
|
|
||||||
echo "Building dictionary"
|
echo "Building dictionary"
|
||||||
echo runCmd("nim c --run --threads:on -d:release -d:lto src/process.nim")
|
let output = runCmd("nim c --run --threads:on -d:release -d:lto src/process.nim BNC/2554/download/Texts src/")
|
||||||
|
echo output.strip().splitlines()[^1]
|
||||||
|
|
||||||
task(showexec, "this is a test"):
|
|
||||||
let (output, exitCode) = gorgeEx("ls BNC")
|
|
||||||
echo output
|
|
||||||
echo exitCode
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
before(build):
|
before(build):
|
||||||
if not pathExists("src/dictionary.txt"):
|
if not dirExists("src/dictionary.txt"):
|
||||||
dictionaryTask()
|
dictionaryTask()
|
||||||
|
@ -51,6 +51,9 @@ when isMainModule:
|
|||||||
paramStr(1)
|
paramStr(1)
|
||||||
else:
|
else:
|
||||||
r"../BNC/2554/download/Texts/"
|
r"../BNC/2554/download/Texts/"
|
||||||
|
|
||||||
|
if not dirExists(basePath):
|
||||||
|
quit("Could not locate datafiles: directory " & basePath & " does not exist.")
|
||||||
|
|
||||||
var paths: seq[string]
|
var paths: seq[string]
|
||||||
for path in walkDirRec(basePath):
|
for path in walkDirRec(basePath):
|
||||||
@ -76,6 +79,15 @@ when isMainModule:
|
|||||||
counts.inc(word, count)
|
counts.inc(word, count)
|
||||||
|
|
||||||
counts.sort()
|
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."
|
echo "Done. Finished in ", (getMonoTime() - start).inMilliseconds.float / 1000, " seconds."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user