[Trennmuster] Makefile
Stephan Hennig
mailing_list at arcor.de
So Jul 6 20:48:07 CEST 2014
Am 06.07.2014 16:03, schrieb Stephan Hennig:
> Ich habe mir noch keine weiteren Gedanken darüber gemacht, aber ich
> bastele schnell man ein kleines Extraktionsskript in Lua und stelle
> das dann hier zur weiteren Diskussion.
Angehängt ein Skript, welches die Wörter einer Rechtschreibung ohne
weitere Bearbeitung aus der Wortliste extrahiert. Das Skript
verarbeitet eine Wortliste auf der Standardeingabe. Im Gegensatz zum
Skript extract-tex.pl muss explizit eine Varietät per Option ausgewählt
werden. Zum Beispiel
$texlua skripte/extract-variety.lua -r < wortliste > wortliste.refo
Wie im Skript extract-tex.pl werden bei Wahl der Schweizer Varietät auch
Versalschreibungen aus Feld 6 verwendet, falls die Felder 5 und 8 leer
sind, zum Beispiel 'Ausschusssitzung' mit drei Konsonanten und folgendem
Vokal. Ich bin mir allerdings nicht sicher, ob das tatsächlich
notwendig ist. Jedenfalls haben die Ergebnislisten von extract-tex.pl
und extract-variety.lua für alle drei Sprachvarietäten jeweils eine
identische Zeilenzahl.
Die restlichen beiden Schritte zur Erzeugung einer Eingabeliste für
Patgen sind:
a) Bearbeitung der gewünschten Markierungen (Trennstellen,
Haupttrennstellen, ck-Trennungen, langes S, ...)
b) Umwandlung der Kodierung
Ich halte es für sinnvoll, auch diese Schritte logisch voneinander zu
trennen. Dann kann jeder für a) Skripten in seiner bevorzugten
Programmiersprache schreiben und trotzdem weitestgehend von
existierendem Kode profitieren.
Ein mögliches Problem gibt es: Bei der Bearbeitung durch verschiedene
Skripten steht für Schritt a) die Quellspaltennummer nicht mehr zur
Verfügung. Keine Ahnung, ob es Anwendungsfälle gibt, bei denen das
problematisch werden könnte. Mir fallen momentan keine ein.
Viele Grüße,
Stephan Hennig
-------------- nächster Teil --------------
-- -*- coding: utf-8 -*-
--[[
Copyright 2014 Stephan Hennig
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
--]]
-- To search for modules in path 'skripte/lua', adjust search path in a
-- platform neutral way.
--
-- Read configuration data.
local path_dirsep, path_sep, path_subst = string.match(package.config, '(.-)\n(.-)\n(.-)\n')
-- Augment search path.
package.path = package.path
.. path_sep .. 'lua' .. path_dirsep .. path_subst .. '.lua'
.. path_sep .. 'skripte' .. path_dirsep .. 'lua' .. path_dirsep .. path_subst .. '.lua'
-- Load modules from plain Lua path.
local hrecords = require('helper_records')
-- Load modules from TEXMF tree.
kpse.set_program_name('luatex')
local alt_getopt = require('alt_getopt')
-- Declare valid options.
local long_opts = {
help = 'h',
refo = 'r',
swiss = 's',
trad = 't'
}
local opt = alt_getopt.get_opts(arg, 'hrst', long_opts)
-- Output help message.
local function help()
local progname = arg[0]
print('usage: texlua ' .. progname .. [[ [options]
Reads a word list database from stdin, extracts words of a certain language variety, and writes a simple word list to stdout.
long short arg description
--help -h print help
--refo -r extract reformed spellings
--swiss -s extract Swiss traditional spellings
--trad -t extract traditional spellings
]]
)
end
--- Extract traditional spellings.
local function extract_trad()
for record in io.lines() do
local field = hrecords.split(record)
local word = field[2] or field[3] or field[5] or field[6]
-- Spelling present in this variety?
if word then
io.write(word, '\n')
end
end
end
--- Extract Swiss traditional spellings.
-- Including traditional captial spellings from field 6, that are not
-- explicitly marked as present in Swiss traditional orthography, like
-- `Ausschusssitzung'. Note the triple-s followed by a vocal!
local function extract_swiss()
for record in io.lines() do
local field = hrecords.split(record)
local word = field[2] or field[3] or field[5] or field[8] or field[6]
-- Spelling present in this variety?
if word then
io.write(word, '\n')
end
end
end
-- Extract reformed spellings.
local function extract_refo()
for record in io.lines() do
local field = hrecords.split(record)
local word = field[2] or field[4] or field[5] or field[7]
-- Spelling present in this variety?
if word then
io.write(word, '\n')
end
end
end
-- Run requested action.
if opt.h then
help()
os.exit()
elseif opt.t then
extract_trad()
elseif opt.s then
extract_swiss()
elseif opt.r then
extract_refo()
else
io.stderr:write('Please specify a language variety!\n')
help()
os.exit(1)
end
Mehr Informationen über die Mailingliste Trennmuster