WiktionaryDumps to words: Difference between revisions
m
simplify state logic
m (write to a file not to the terminal) |
m (simplify state logic) |
||
Line 312:
=={{header|Julia}}==
Uses Regex and a state
<lang julia>using CodecBzip2
function getwords(io::IO, output::IO, languagemark = "==French==", maxwords = 80)
title, txopen, txclose = "<title>", "<text", "</text>"
wordcount, titleword = 0, ""
for line in eachline(io)
if occursin(title, line)
titleword = (m = match(r"<title>([^<]+)</title>", line)) != nothing ? m[1] : ""
elseif occursin(txopen, line)
elseif occursin(languagemark, line)
if got_text_last && titleword != ""
Line 330:
(wordcount += 1) >= maxwords && break
end
elseif occursin(txclose, line)
end
end
|