https://github.com/liblouis/rewrite-louis
A liblouis table parser based on instaparse. Converts tables to Clojure data structures.
https://github.com/liblouis/rewrite-louis
Last synced: 11 months ago
JSON representation
A liblouis table parser based on instaparse. Converts tables to Clojure data structures.
- Host: GitHub
- URL: https://github.com/liblouis/rewrite-louis
- Owner: liblouis
- License: epl-2.0
- Created: 2021-11-26T15:41:48.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-02T11:56:33.000Z (over 4 years ago)
- Last Synced: 2025-06-25T18:15:20.118Z (about 1 year ago)
- Language: Clojure
- Size: 17.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
- License: LICENSE
Awesome Lists containing this project
README
* rewrite-louis
An experimental parser for liblouis tables based on [[https://github.com/engelberg/instaparse][instaparse]]. Given
a liblouis table the parser returns plain old Clojure data. This can
be used for example to rewrite the table into any other format.
** Usage
#+begin_src clojure
(require '[instaparse.core :as insta])
(def louis-parser (insta/parser (clojure.java.io/resource "louis.bnf")))
(louis-parser (slurp "~/src/liblouis/tables/ar-ar-comp8.utb"))
#+end_src
which will return
#+begin_src clojure
[:table
[:comment "afr#1#Afrikaans Uncontracted#za#Afrikaans onverkort"]
,,,
[:comment " ."]
[:include "en-ueb-g1.ctb"]]
#+end_src
*** Command line
#+begin_src shell
find ~/src/liblouis/tables -type f -print | grep -v -e '\.dic' -e 'Makefile' -e 'maketablelist.sh' -e 'README' | sort | xargs lein run
#+end_src
** Status
As it stands the parser can parse probably around 95% of the tables in
the liblouis distribution. At the moment it has no support for
- continuation lines (da-dk-g16-lit.ctb, da-dk-g26-lit.ctb, da-dk-g26l-lit.ctb)
- huge tables cause a OutOfMemoryError (GC overhead limit exceeded)
(zh-chn.ctb, zhcn-g1.ctb, zhcn-g2.ctb, ko-chars.cti, zh-tw.ctb, etc)
** Acknowledgements
A lot of the [[https://github.com/liblouis/rewrite-louis/blob/main/resources/louis.bnf][EBNF grammar]] was basically re-used from [[https://github.com/liblouis/louis-parser][louis-parser]] and
its liblouis table grammar definition in the form of [[https://en.wikipedia.org/wiki/Parsing_expression_grammar][Parsing
expression grammar]].
** License
Copyright © 2021 Swiss Library for the Blind, Visually Impaired and Print Disabled
This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following
Secondary Licenses when the conditions for such availability set forth
in the Eclipse Public License, v. 2.0 are satisfied: GNU General
Public License as published by the Free Software Foundation, either
version 2 of the License, or (at your option) any later version, with
the GNU Classpath Exception which is available at
https://www.gnu.org/software/classpath/license.html.