# liblouis: Hungarian Grade 2 table
#
# -----------
#-index-name: Hungarian, contracted
#-display-name: Hungarian contracted braille
#
#+language:hu
#+type:literary
#+contraction:full
#+grade:2
# Marked as "direction:forward" by Bue Vester-Andersen
# as tests only run forward.
#+direction:both
#
# TODO: Please add a reference to official documentation about
# the implemented braille code. Preferably submit the documents
# to https://github.com/liblouis/braille-specs.
# -----------
#
#  Copyright (C) 2017-2022 Attila Hammer from IT Foundation for the Visually Impaired - Hungary. www.infoalap.hu
#
#  This file is part of liblouis.
#
#  liblouis is free software: you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as
#  published by the Free Software Foundation, either version 2.1 of the
#  License, or (at your option) any later version.
#
#  liblouis 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
#  Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public
#  License along with liblouis. If not, see
#  <http://www.gnu.org/licenses/>.
#
#  Maintained by Attila Hammer  hammer.attila@infoalap.hu
#
# If you found bugs with hungarian grade1 table, report it with following address:
# Attila Hammer <hammer.attila@infoalap.hu
#If you have a Launchpad account, report table related requests with following bug tracker address: https://bugs.launchpad.net/belin

attribute notaccentedletters abcdefghijABCDEFGHIJ-
attribute accentedletters áéíöőüűúóklmnopqrstuvwxyz
include hu-backtranslate-correction.dis
include hu-chardefs.cti
include hu-hu-g2_exceptions.cti
include hu-exceptionwords.cti
include hu-backtranslate-word-corrections.cti
include braille-patterns.cti
#Braille indicators
nonumsign 6
numsign 3456
capsletter 46a
noback pass4 @46a ? # remove in a second pass because single capital letters are not indicated
begcapsword 46
emphclass italic
emphclass underline
emphclass bold
begemph italic 356
endemph italic  236
begemph bold 356
endemph bold 236
begemph underline 356
endemph underline 236
begcomp 456-346
endcomp 456-156
# literary forms of the decimal digits
include litdigits6Dots.uti
include hu-hu-g1_braille_input.cti
midendnumericmodechars ,:.-
numericnocontchars abcdefghijABCDEFGHIJ-
attribute notaccentedletters abcdefghijABCDEFGHIJ-
attribute accentedletters áéíöőüűúóklmnopqrstuvwxyz
#Correcting forward translation when after a number following a hyphen
#character, and a literary digit letter (for example a, b, c, etc).
#This situation not need putting the dot 6 combination
noback pass2 $D[@36-6]%notaccentedletters @36
noback pass3 $D[@36-46a-6]%notaccentedletters @36
noback pass2 $D[@36-36-6]%notaccentedletters @36-36
#Correct forward translation, when after a number not need putting the dot 6 prefix the v abbreviation (for example the 4-gyel string
noback pass2 $D[@6-1236] @1236
#Correcting backward translation too, because for example the „#bj-ai”,
#„#be-ei” eurobraille output since Liblouis 3.9.0 version producing numbers
#the back translation, not the „20-ai”, „25-ei” strings.
#wrong backtranslated output is „20-19”, „25-59”
nofor pass2 $D[@36-36]%notaccentedletters @36-36-6
nofor pass2 $D[@36]%notaccentedletters @36-6
nofor correct "—annyi" "--ai"
nofor correct "—ennyi" "--ei"
nofor correct $D1-30["--annyi"] "--ai"
nofor correct $D1-30["--ennyi"] "--ei"
nofor correct $D1-30["-annyi"] "-ai"
nofor correct $D1-30["-ennyi"] "-ei"
#Special letter replacements
always cs 146	General need replacing cs letters with a combined dot combination
always ccs 146-146	General need replacing ccs letters with a combined dot combination
always csz 14-156
always cszs 146-345
always ccsz 14-14-156
always gy 1456	General need replacing gy letters with a combined dot combination
always ggy 1456-1456	General need replacing ggy letters with a combined dot combination
always ly 456
always lly 456-456	General need replacing ly letters with a combined dot combination
always ny 1246	General need replacing ny letters with a combined dot combination
always nny 1246-1246	General need replacing nny letters with a combined dot combination
always ty 1256	General need replacing ty letter pairs with a combined dot combination
always tty 1256-1256		General need replacing ty letter pairs with a combined dot combination
always sz 156	General need replacing sz letters with a combined dot combination
always ssz 156-156
always zsz 126-156
always zs 345	General need replacing zs letters with a combined dot combination
always zzs 345-345	General need replacing zs letters with a combined dot combination
always " 236	Need this rule to present one left quotation mark if the user firsttyping the " character
always ( 2346	Need this rule to the user always see 2346 dot combination if type first ( character a text
always ) 1356	Need this rule to the user always see 2346 dot combination if type first ) character a text
#Other exceptions With need marking different dot combination
always # 123456
always $ 5-145
always % 3456-245-356
always ~ 5-2345
always < 5-13
always > 46-2
always / 5-2
always | 5-1245
always { 5-2346
always } 5-1356
always [ 46-2346
always ] 46-1356
always \\ 5-16
always ^ 5-124
always ` 5-14
noback always Æ 1
always lyú 456-346
always lysz 456-156

#define context rules related need classes
attribute orszag O
attribute nevelo A
attribute oneromannumber I
attribute fiveromannumber V
attribute tenromannumber X
attribute fiftyromannumber L 
attribute hundredromannumber C
attribute nagysz S

#handle extra special abbreviation rules with context opcodes
#not always need abbreviate the ország word, for example person and continent names. The next rule handle this situation
noback context $U["rszág"]$s$U$a @1235-156-4-1245

#general, need abbreviate the "volt" word, but this word some time meaning hungarian language the electric measurement.
#following context rules handles this extra situation
noback context [%nevelo$s"Volt"]$s"egy"$s @2-1236-135-123-2345
noback context ["volt"]$s"körül" @1236-135-123-2345
noback context ["egyenlő\shány\svolt"] @15-1456-15-1345-123-12456-0-125-4-1246-0-1236-135-123-2345
noback context $l["ány\svolt\sáram"] @4-1246-0-1236-135-123-2345-0-4-1235-1-134

#some context rules with the "az" and "a" verbs related
noback context ["az\sokoz"] @1-126-0-135-13-135-126
noback context ["az\saz\s"] @1-126-0-3	General, if a text part have the "az" word, need joining the second word before a dot3 cell dot. But, if a text part have the az word two times, the first az word not need abbreviate with dot2 and joining the second az word, the first az word need presenting with following dots: 1-126-0. An example: az az igazság
noback context ["az\sa\s"] @1-126-0-2
noback context [%nevelo"z\sa\s"] @1-126-0-2
noback context ["az\s"]"is"$p @1-126-0
noback context ["az\s"]"is\s" @1-126-0
noback context [%nevelo"z\sis\s"] @1-126-0-24-0
noback context [%nevelo"z\s"]"is"$p @1-126-0
noback context ["a\s"]"és" @1-0
noback context ["az\segyelőre"] @1-126-0-15-1456-15-123-12456-1235-15
noback context ["az\sugyanis"] @1-126-0-136-1456-1-1345-24-234
noback context ["az\sadja"] @1-126-0-1-145-245-1
noback context ["az\sadta"] @1-126-0-1-145-2345-1
noback context ["az\ssem"]$s @1-126-0-234-15-134
noback context ["az\ssem"]$p @1-126-0-234-15-134
noback context ["az\saz\ssem"]$p @1-126-0-1-126-0-234-15-134
noback context ["az\slenne"] @1-126-0-123-15-1345-1345-15
noback context ["az\slesz"] @1-126-0-123
noback context ["az\sleszel"] @1-126-0-123-15-156-15-123
noback context ["az\sleszek"] @1-126-0-123-15-156-15-13
noback context ["az\s"]"volt" @1-126-0
noback context [%nevelo"z"]$s"az"$s @1-126
noback context [%nevelo"z"]$s"okoz" @1-126
noback context [%nevelo"z"]$s"egyelőre" @1-126
noback context [%nevelo"z"]$s"ugyanis" @1-126
noback context [%nevelo"z"]$s"adja" @1-126
noback context [%nevelo"z"]$s"adta" @1-126
noback context [%nevelo"z"]$s"lenne" @1-126
noback context [%nevelo"z"]$s"sem" @1-126
noback context [%nevelo"z"]$s"lesz"$s @1-126
noback context [%nevelo"z"]$s"lesz" @1-126
noback context [%nevelo"z"]$s"lesz"$p @1-126
noback context [%nevelo"z"]$s"volt" @1-126
noback context [%nevelo"z"]$s"volt"$p @1-126
noback context ["az\salábbi"] @1-126-0-1-123-4-12-12-24
noback context [%nevelo"z\salábbi"] @1-126-0-1-123-4-12-12-24
#general, after comma character need joining the next text part with after the comma character, but need some context rules to this braille standard works gracefully
noback context [",\saz\sa\s"] @2-1-126-0-2
noback context [",\saz\saz\s"] @2-1-126-0-3
noback context [",\s"] @2
noback context [",\n"] @2
noback context [",\n\r"] @2
noback context $a["\na\s"] @0-2
#handle roman numbers related special rules
noback context [%oneromannumber]"." @46-24
noback context $U[%oneromannumber]"." @24
noback context [%fiveromannumber]"." @46-1236
noback context $U[%fiveromannumber]"." @1236
noback context [%tenromannumber]"." @46-1346
noback context $U[%tenromannumber]"." @1346
noback context [%fiftyromannumber]"." @46-123
noback context $U[%fiftyromannumber]"." @123
noback context [%hundredromannumber]"." @46-14
noback context $U[%hundredromannumber]"." @14

#some country names related context rules
noback context $U"io"$s["de"]$s$U"anerio" @145-15 
noback context $U"io"$s["de"]$s$U"aneiro" @145-15 

#General, need abbreviate end of llal suffix part, but the vállal word have some exceptions, depending the text context.
#Following context rules gracefully handle this different situations
noback context ["vállal"]$s"ige\s" @1236-4-123-123-1-123
noback context "ciát"$s["vállal"] @1236-4-123-123-1-123	For example the "garanciát vállal" context not need abbreviate the end of llal suffix
noback context "séget"$s["vállal"] @1236-4-123-123-1-123	For example felelősséget vállal context not need abbreviate the end of llal word suffix
noback context ["kockázatot\svállal"] @13-135-14-13-4-126-1-2345-135-2345-0-1236-4-123-123-1-123	This text part doesn't need abbreviate the llal suffix with end of vállal word, and the kockázatot text part need presenting with contracted word
noback context ["vállal"]$s"el" @1236-4-123-123-1-123
noback context ["vállal"]$s"felelősséget" @1236-4-123-123-1-123
noback context $l["em\svállal"] @0-1236-4-123-123-1-123	The "Nem vállal" and "nem vállal" text parts doesn't need abbreviate the end of llal suffix, only the nem and Nem word part
noback context $l["észt\svállal"] @16-156-2345-0-1236-4-123-123-1-123
noback context "ligha"$s["vállal"] @1236-4-123-123-1-123
noback context ["vállal"]$s"állás" @1236-4-123-123-1-123
noback context ["vállal"]$s"munkát" @1236-4-123-123-1-123
noback context ["vállal"]$s$s"fogcsonk" @1236-4-123-123-1-123
noback context ["vállal"]$s"fogcsonk" @1236-4-123-123-1-123
noback context ["vállal"]$s"kezes" @1236-4-123-123-1-123
noback context ["vállal"]$s"magára" @1236-4-123-123-1-123
always átvállal 4-2345-1236-4-123-123-1-123
always bevállal 12-15-1236-4-123-123-1-123
always elvállal 15-123-1236-4-123-123-1-123
noback context ["\f,"] @2
noback context $l["+"]$s$l @0-1234-123-136-156	If a word ends with a + simbol and follow up a next word after a space character, need replacing the + punctuation character with the "plusz" text

#names related context rules, when not need abbreviate a general abbreviated word part
noback context $U["oldog"]$s$U$a @135-123-145-135-1245	For example Boldog Gizella name not need abbreviate the boldog word part with 12-1245 dots
noback context $U["oldog"]$l1-30$s$U$a @135-123-145-135-1245	For example Boldogfalvi Tamás name not need abbreviate the boldog word part with 12-1245 dots
noback context $U$l1-30$s["de"]$s$U$a @145-15	General, need abbrewiate the de word with 1545 dots, but hungarian literary texts some spanish or portuguese names need replacing the abbreviated de word with normal 145-15 dots. For example: Rio de Janeiro, 
noback context $U["ond"]$l1-30$s$U$a @135-1345-145	General need abbreviate the gond word part with 1245-145 dots, but in names, this is not need. For example: Gonda János, Gondos Réka.
noback context [%nagysz"zabad"]$s$U$a @156-1-12-1-145
noback context [%nagysz"zabad"]$l1-30$s$U$a @156-1-12-1-145
always ponta-kormá 1234-135-1345-2345-1-36-13-135-1235-134-4

noback context [", "] @2
noback context $U["emmel"]$s$U$a @15-134-134-15-123	For example Temmel Anikó, Temmel Márta names not need apply the suffix abbreviation
noback context $U["an"]$s$U"ogh" @1-1345

#Some pass2 step related rules
noback pass2 @135-1235-156-4-1245-1456 @135-1245-1456
noback pass2 @1234-16-1345-126 @1234-126
noback pass2 @13-15-1235-15-234-16-234-234-15-123 @13-234-16-234-1236
noback pass2 @13-15-1235-15-234-16-234 @13-234-16-234
noback pass2 @12345-156-156-15-13 @12345-15-13
noback pass2 @124-135-1235-1235-4-234 @1235-1235-4-234
noback pass2 @145-16-123-136-2345-4-1345 @145-16-123-136
noback pass2 @1236-24-123-4-1245 @1236-1245
space \xe000 46a
noback pass2 @1236-1-13-135-13$s$s.@1236-24-123-4-1245 @1236-1-13-135-13-0-1236-24-123-4-1245
always ä 5-1
uppercase Ä 5-1
noback context $l$p["–"] @36-36
noback context $l["–"] @36-36
noback always \\_ 6 letter sign before Roman page numbers
undefined 26
