Debian Codegraph @

tools/lou_maketable.d/generate_alphabet.py

raw symbols SCIP
1 # liblouis Braille Translation and Back-Translation Library
2 #
3 # Copyright (C) 2017 Bert Frees
4 #
5 # This file is part of liblouis.
6 #
7 # liblouis is free software: you can redistribute it and/or modify it
8 # under the terms of the GNU Lesser General Public License as published
9 # by the Free Software Foundation, either version 2.1 of the License, or
10 # (at your option) any later version.
11 #
12 # liblouis is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
16 #
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with liblouis. If not, see <http://www.gnu.org/licenses/>.
19 #
20
21 import argparse
22 from itertools import groupby
23 from utils import *
24
25 def main():
26 parser = argparse.ArgumentParser(description="Generate translate file for patgen.")
27 parser.add_argument('-d', '--dictionary', required=True, dest="DICTIONARY",
28 help="dictionary file")
29 parser.add_argument('-t', '--table', required=True, dest="TABLE",
30 help="translation table to be used for converting letters to lowercase")
31 args = parser.parse_args()
32 load_table(args.TABLE)
33 conn, c = open_dictionary(args.DICTIONARY)
34 c.execute("SELECT text FROM dictionary WHERE braille IS NOT NULL")
35 alphabet = ""
36 for text, in c.fetchall():
37 alphabet = "".join(set(alphabet + text))
38 print("")
39 for k, g in groupby(sorted(alphabet, key=to_lowercase), to_lowercase):
40 g = list(g)
41 g.remove(k)
42 println(" " + " ".join([k] + g))
43 conn.close()
44
45 if __name__ == "__main__": main()