1-- (encoding:utf-8) 2 3-- GUIONIZADO DE PALABRAS 4-- ~~~~~~~~~~~~~~~~~~~~~ 5-- v 4.7 6-- 7-- License: MIT/X11 8-- 9-- Copyright (c) 1993, 1997 Javier Bezos 10-- Copyright (c) 2001-2015 Javier Bezos and CervanTeX 11-- 12-- Permission is hereby granted, free of charge, to any person obtaining a copy 13-- of this software and associated documentation files (the "Software"), to deal 14-- in the Software without restriction, including without limitation the rights 15-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16-- copies of the Software, and to permit persons to whom the Software is 17-- furnished to do so, subject to the following conditions: 18-- 19-- The above copyright notice and this permission notice shall be included in 20-- all copies or substantial portions of the Software. 21-- 22-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28-- SOFTWARE. 29-- 30-- For further info, bug reports and comments: 31-- 32-- http://www.tex-tipografia.com/spanish_hyphen.html 33 34---------- 35 36-- ethymologic, trailing no, bad words, prefixes, consonant + h, tl 37 38patfile = io.open('eshyph.tex', 'w') 39patfile:write('\\patterns{\n') 40 41-- Basic patters 42-- Using the characters iterator in luatex 43 44digraphs = 'ch ll' 45liquids = 'bl cl fl gl kl pl vl br cr dr fr gr kr pr rr tr vr' 46avoid = 'tl ts tx tz' 47silent = 'h' 48chrl = 'chr chl' 49letters = 'bcdfghjklmnpqrstvwxyz' 50 51for n in letters:gmatch('.') do 52 if silent:find(n) then 53 patfile:write(' 4' .. n .. '.') 54 else 55 patfile:write('1' .. n .. ' 4' .. n .. '. .' .. n .. '2') 56 end 57 for m in letters:gmatch('.') do 58 pat = n .. m 59 if digraphs:find(pat) then 60 patfile:write(' ') 61 elseif liquids:find(pat) then 62 patfile:write(' ') 63 elseif avoid:find(pat) then 64 patfile:write(' ') 65 elseif silent:find(m) then 66 patfile:write(' 2' .. n .. '1' .. m) 67 else 68 patfile:write(' 2' .. pat) 69 end 70 end 71 patfile:write('\n') 72end 73 74patfile:write('1ñ 4ñ.\n') 75 76for n in digraphs:gmatch('%S+') do 77 patfile:write(n:sub(1,1) .. '4' .. n:sub(2,2) .. ' 4' .. n .. '.') 78 for m in letters:gmatch('.') do 79 pat = n .. m 80 if chrl:find(pat) then 81 patfile:write(' ' .. n .. '2' .. m) 82 else 83 patfile:write(' 2' .. pat) 84 end 85 end 86 patfile:write('\n') 87end 88 89for n in liquids:gmatch('%S+') do 90 patfile:write(n:sub(1,1) .. '2' .. n:sub(2,2) .. ' 4' .. n .. '.') 91 for m in letters:gmatch('.') do 92 patfile:write(' 2' .. n .. '2' .. m) 93 end 94 patfile:write('\n') 95end 96 97letters = 'bcdlmnrstxy' 98etim = 'pt ct cn ps mn gn ft pn cz tz ts' 99 100for n in etim:gmatch('%S+') do 101 for m in letters:gmatch('.') do 102 patfile:write('2' .. m .. '3' .. n:sub(1,1) .. '2' .. n:sub(2,2) .. ' ') 103 end 104 patfile:write('4' .. n .. '.\n') 105end 106 107src = io.open('eshyph.src') 108 109function prefix(p) 110 if p:match('r$') then 111 p = p:sub(1,-2) .. '2' .. p:sub(-1) .. '1' 112 patfile:write(p:sub(1,-2) .. '3r\n') 113 elseif p:match('[aeiou]$') then 114 p = p .. '1' 115 patfile:write(p .. 'h\n') 116 end 117 patfile:write(p .. 'a2 ' .. p .. 'e2 ' .. p .. 'i2 ' .. p .. 'o2 ' .. p .. 'u2\n') 118 patfile:write(p .. 'á2 ' .. p .. 'é2 ' .. p .. 'í2 ' .. p .. 'ó2 ' .. p .. 'ú2\n') 119 120end 121 122for ln in src:lines() do 123 ln = ln:match('[^%%]*') 124 for p in ln:gmatch('%S+') do 125 if p:match('/(.*)/') then 126 prefix(p:match('/(.*)/')) 127 elseif p:sub(1,1) == '*' then 128 patfile:write('de2s3' .. p:sub(2) .. '\n') 129 else 130 patfile:write(p .. '\n') 131 end 132 end 133end 134 135patfile:write('}') 136patfile:close() 137