WiktionaryDumps to words: Difference between revisions
m
→{{header|Wren}}: Minor tidy and rerun
(Added Wren) |
m (→{{header|Wren}}: Minor tidy and rerun) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 4:
Make a file that can be useful with [https://en.wikipedia.org/wiki/Spell_checker spell checkers] like [https://fr.wikipedia.org/wiki/Ispell Ispell] and [https://en.wikipedia.org/wiki/GNU_Aspell Aspell].
Use the [https://dumps.wikimedia.org/enwiktionary/latest/enwiktionary-latest-pages-articles.xml.bz2 wiktionary dump] (input) to create a file equivalent
=={{header|C}}==
<
#include <stdlib.h>
#include <stdbool.h>
Line 205:
return 0;
}</
{{out}}
Line 229:
=={{header|Java}}==
<
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.SAXException;
Line 288:
}
}
}</
{{out}}
Line 311:
=={{header|Julia}}==
Uses Regex and a state variable instead of XML parsing. Default setting prints the first 80 French words found.
<
function getwords(io::IO, output::IO; languagemark = "==French==", maxwords = 80)
Line 341:
getwords(stream, stdout) # or open a file to write to and use its IO handle instead of stdout
</
<pre>
gratis
Line 430:
Using the library [http://erratique.ch/software/xmlm xmlm]:
<
let i = Xmlm.make_input ~strip:true (`Channel stdin) in
let title = ref "" in
Line 463:
then print_endline !title
end
done</
{{out}}
Line 485:
=={{header|Perl}}==
{{trans|Raku}}
<
use strict;
Line 529:
}
}
)</
{{out}}
<pre>
Line 542:
Does not rely on wget/bzcat etc. Downloads in 16K or so blocks, unpacks one block at a time in memory, terminates properly when 5 or more words are found.<br>
Tested on Windows, should be fine on Linux as long as you can provide a suitable bz2.so
<!--<
<span style="color: #008080;">constant</span> <span style="color: #000000;">url</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"https://dumps.wikimedia.org/enwiktionary/latest/enwiktionary-latest-pages-articles.xml.bz2"</span>
Line 631:
<span style="color: #7060A8;">curl_easy_cleanup</span><span style="color: #0000FF;">(</span><span style="color: #000000;">curl</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Total downloaded: %s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">file_size_k</span><span style="color: #0000FF;">(</span><span style="color: #000000;">tbr</span><span style="color: #0000FF;">)})</span>
<!--</
{{out}}
<pre>
Line 644:
=={{header|Raku}}==
I misunderstood the data format and now just copy verbatim from Julia entry the processing logics ..
<syntaxhighlight lang="raku"
use LWP::Simple;
Line 710:
my $ua = CustomLWP.new: URL => $URL ;
$ua.CustomRequest>>.say</
{{out}}
<pre>
Line 727:
An embedded program so we can use libcurl and libbzip2.
Rather than downloading the full 800MB .bz2 file and then decompressing it, we abort the download after receiving no more than the first 512 KB and then decompress that ignoring the resultant BZ_UNEXPECTED_EOF error. This turns out to be enough to find the first
<
import "./pattern" for Pattern
Line 789:
gotTextLast = false
}
}</
<br>
We now embed this script in the following C program, build and run.
<
#include <stdio.h>
Line 988:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
Line 1,004:
free(script);
return 0;
}</
{{out}}
Line 1,030:
fable
a-
</pre>
|