| 1 |
ding2tei-haskell |
| 2 |
================ |
| 3 |
|
| 4 |
A program to convert the Ding [0] dictionary into the TEI [1] format, to be |
| 5 |
used within the FreeDict project [2]. |
| 6 |
|
| 7 |
This program was written as part of a Bachelor's thesis. See doc/thesis.pdf. |
| 8 |
|
| 9 |
|
| 10 |
Dependencies |
| 11 |
------------ |
| 12 |
|
| 13 |
* main ding2tei program: |
| 14 |
* Haskell (Glasgow Haskell Compiler / GHC) |
| 15 |
* base |
| 16 |
* containers (Data.Map, Data.Set) |
| 17 |
* transformers (Control.Monad.Trans.{State,Writer}) |
| 18 |
* pretty (Text.PrettyPrint) |
| 19 |
* haskell-xml (Text.XML.Light) |
| 20 |
* safe (Safe.Exact) |
| 21 |
* Happy |
| 22 |
* Alex |
| 23 |
* preprocessing: |
| 24 |
* Bash |
| 25 |
* sed (with support for `-E`; e.g., GNU sed, OpenBSD's sed) |
| 26 |
* `make` (optional) |
| 27 |
* GNU make |
| 28 |
* standard UNIX utilities (provided by, e.g., GNU coreutils) |
| 29 |
* curl (`make download-ding-1.9`) |
| 30 |
* xz (`make download-ding-1.9`) |
| 31 |
|
| 32 |
On Debian-based distributions: |
| 33 |
|
| 34 |
# apt install ghc libghc-xml-dev libghc-safe-dev happy alex bash sed make \ |
| 35 |
coreutils curl xz-utils |
| 36 |
|
| 37 |
|
| 38 |
Locale |
| 39 |
------ |
| 40 |
|
| 41 |
Use a UTF-8 locale, otherwise some things might produce unexpected results or |
| 42 |
even fail. In particular, do not use the C locale. |
| 43 |
|
| 44 |
|
| 45 |
Obtain the Ding dictionary |
| 46 |
-------------------------- |
| 47 |
|
| 48 |
$ make download-ding-1.9 |
| 49 |
|
| 50 |
Alternatively, it can be manually downloaded from: |
| 51 |
|
| 52 |
https://ftp.tu-chemnitz.de/pub/Local/urz/ding/de-en/ |
| 53 |
|
| 54 |
and stored (uncompressed) at: |
| 55 |
|
| 56 |
dict/ding/de-en.txt |
| 57 |
|
| 58 |
|
| 59 |
Build ding2tei |
| 60 |
-------------- |
| 61 |
|
| 62 |
$ make |
| 63 |
|
| 64 |
You may need to include `-dynamic` in HCFLAGS; e.g.: |
| 65 |
|
| 66 |
$ make HCFLAGS='-O2 -Wall -dynamic' |
| 67 |
|
| 68 |
|
| 69 |
Build TEI dictionaries |
| 70 |
---------------------- |
| 71 |
|
| 72 |
$ make deu-eng |
| 73 |
$ make eng-deu |
| 74 |
|
| 75 |
Note: The main program (ding2tei) allocates a lot of memory, around 5.7 GiB, |
| 76 |
when applied to the full Ding dictionary. |
| 77 |
|
| 78 |
|
| 79 |
Debug / Run ding2tei manually |
| 80 |
----------------------------- |
| 81 |
|
| 82 |
# TODO: make (alex, happy) |
| 83 |
$ make haskell-source-files |
| 84 |
$ ghci -i -ibuild:src -XRecursiveDo Test |
| 85 |
>> parseLine $ scan "some dictionary :: line\n" |
| 86 |
>> pretty $ parseLine $ scan (examples !! 0) |
| 87 |
>> (Just ding, log) = parse $ scan $ header ++ (concat examples) |
| 88 |
>> pretty ding |
| 89 |
>> tei = ding2tei $ enrichDirected $ enrichUndirected ding |
| 90 |
>> putStr $ prettyTEI $ tei |
| 91 |
>> :q |
| 92 |
|
| 93 |
$ ./ding2tei --help |
| 94 |
$ ./ding2tei doc/examples/test.ding - | pager |
| 95 |
|
| 96 |
See also: |
| 97 |
|
| 98 |
src/Main.hs |
| 99 |
GNUmakefile |
| 100 |
|
| 101 |
|
| 102 |
Usage with the FreeDict tools |
| 103 |
----------------------------- |
| 104 |
|
| 105 |
To use the resulting TEI files with the FreeDict tools: |
| 106 |
|
| 107 |
$ make -C dict/tei/lg1-lg2 |
| 108 |
|
| 109 |
Notes: |
| 110 |
* Above, lg1-lg2 should be either of deu-eng and eng-deu. |
| 111 |
* Memory usage of the FreeDict tools is even higher than that of ding2tei. |
| 112 |
* Running time is quite long (~ 1 day). |
| 113 |
* See <https://github.com/freedict/tools> for more information. |
| 114 |
|
| 115 |
|
| 116 |
Licensing |
| 117 |
--------- |
| 118 |
|
| 119 |
ding2tei-haskell is distributed under the GNU Affero General Public License |
| 120 |
(AGPL), version 3 or later. |
| 121 |
|
| 122 |
See the license headers in the source files and the license itself for details |
| 123 |
(should be supplied with this program under the name COPYING). |
| 124 |
|
| 125 |
The Ding source is licensed under the GNU General Public License (GPL), version |
| 126 |
2 or later. In the context of this program, version 3 of the license should be |
| 127 |
considered, since it allows combining with the AGPLv3. (Likely, later versions |
| 128 |
will also allow combining.) |
| 129 |
|
| 130 |
The combination of the Ding dictionary and this program form a combined work, |
| 131 |
the resulting TEI dictionary is an "object form" of this combined work, in |
| 132 |
terms of both the GPL and AGPL. |
| 133 |
|
| 134 |
|
| 135 |
Author |
| 136 |
------ |
| 137 |
|
| 138 |
ding2tei-haskell is written by Einhard Leichtfuß. |
| 139 |
Feel free to contact me by e-mail to <[email protected]>. |
| 140 |
|
| 141 |
|
| 142 |
References |
| 143 |
---------- |
| 144 |
|
| 145 |
[0] https://www-user.tu-chemnitz.de/~fri/ding/ |
| 146 |
[1] https://tei-c.org/ |
| 147 |
[2] https://freedict.org/ |