dictionary = {
        "L":               "{:brailleFormat:\n}",
        "S":               "{:brailleFormat: }",
        "2":               "{:brailleFormat:ea}",
        "24":               "{:brailleFormat:i}",
        "245":               "{:brailleFormat:j}",
        "2456":               "{:brailleFormat:w}",
        "246":               "{:brailleFormat:ow}",
        "25":               "{:brailleFormat:cc}",
        "25/25":               "{:brailleFormat:∷}",
        "256":               "{:brailleFormat:.}",
        "256/256/256":               "{:brailleFormat:…}",
        "26":               "{:brailleFormat:en}",
        "23":               "{:brailleFormat:bb}",
        "234":               "{:brailleFormat:s}",
        "2345":               "{:brailleFormat:t}",
        "23456":               "{:brailleFormat:with}",
        "2346":               "{:brailleFormat:the}",
        "235":               "{:brailleFormat:!}",
        "2356":               "{:brailleFormat:gg}",
        "2356/2356":               "{:brailleFormat:′′}",
        "236":               "{:brailleFormat:?}",
        "1":               "{:brailleFormat:a}",
        "12":               "{:brailleFormat:b}",
        "124":               "{:brailleFormat:f}",
        "1245":               "{:brailleFormat:g}",
        "12456":               "{:brailleFormat:er}",
        "1246":               "{:brailleFormat:ed}",
        "125":               "{:brailleFormat:h}",
        "1256":               "{:brailleFormat:ou}",
        "1256/246":               "{:brailleFormat:←}",
        "1256/146":               "{:brailleFormat:↓}",
        "1256/135":               "{:brailleFormat:→}",
        "1256/346":               "{:brailleFormat:↑}",
        "126":               "{:brailleFormat:gh}",
        "123":               "{:brailleFormat:l}",
        "1234":               "{:brailleFormat:p}",
        "12345":               "{:brailleFormat:q}",
        "123456":               "{:brailleFormat:for}",
        "12346":               "{:brailleFormat:and}",
        "1235":               "{:brailleFormat:r}",
        "12356":               "{:brailleFormat:of}",
        "1236":               "{:brailleFormat:v}",
        "14":               "{:brailleFormat:c}",
        "145":               "{:brailleFormat:d}",
        "1456":               "{:brailleFormat:th}",
        "146":               "{:brailleFormat:sh}",
        "15":               "{:brailleFormat:e}",
        "156":               "{:brailleFormat:wh}",
        "16":               "{:brailleFormat:ch}",
        "16/1345":               "{:brailleFormat:children}",
"13":               "{:brailleFormat:k}",
        "134":               "{:brailleFormat:m}",
        "1345":               "{:brailleFormat:n}",
        "13456":               "{:brailleFormat:y}",
        "1346":               "{:brailleFormat:x}",
        "135":               "{:brailleFormat:o}",
        "1356":               "{:brailleFormat:z}",
        "136":               "{:brailleFormat:u}",
        "4/25":               "{:brailleFormat: ̵}",
        "4/26":               "{:brailleFormat:^}",
        "4/234":               "{:brailleFormat:$}",
        "4/1":               "{:brailleFormat:@}",
        "4/124":               "{:brailleFormat:₣}",
        "4/126":               "{:brailleFormat:<}",
        "4/123":               "{:brailleFormat:£}",
        "4/12346":               "{:brailleFormat:&}",
        "4/14":               "{:brailleFormat:¢}",
        "4/15":               "{:brailleFormat:€}",
        "4/16":               "{:brailleFormat: ̸}",
        "4/1345":               "{:brailleFormat:₦}",
        "4/13456":               "{:brailleFormat:¥}",
        "4/46/126":               " [open TN] ",
        "4/46/345":               " [close TN] ",
        "4/6/12456":               "{:brailleFormat:‡}",
        "4/6/1456":               "{:brailleFormat:†}",
        "4/345":               "{:brailleFormat:>}",
        "4/346":               "{:brailleFormat: ̆}",
        "4/35":               "{:brailleFormat:~}",
        "4/36":               "{:brailleFormat: ̄}",
        "45/245":               "{:brailleFormat:°}",
        "45/2456":               "{:brailleFormat:word}",
        "45/25":               "{:brailleFormat: ̈}",
        "45/234":               "{:brailleFormat:§}",
        "45/2345":               "{:brailleFormat:TM}",
        "45/2346":               "{:brailleFormat:these}",
        "45/235":               "{:brailleFormat:ligature}",
        "45/236":               "{:brailleFormat:“}",
        "45/12456":               "{:brailleFormat: ̃}",
        "45/1246":               "{:brailleFormat: ̊}",
        "45/1234":               "{:brailleFormat:¶}",
        "45/12346":               "{:brailleFormat: ̧}",
        "45/1235":               "{:brailleFormat:®}",
        "45/14":               "{:brailleFormat:©}",
        "45/1456":               "{:brailleFormat:those}",
        "45/146":               "{:brailleFormat: ̂}",
        "45/156":               "{:brailleFormat:whose}",
        "45/16":               "{:brailleFormat: ̀}",
        "45/1345":               "{:brailleFormat:ŋ}",
        "45/13456":               "{:brailleFormat:♂}",
        "45/1346":               "{:brailleFormat:♀}",
        "45/136":               "{:brailleFormat:upon}",
        "45/456/2":               "{:brailleFormat:tdm1}",
        "45/456/23":               "{:brailleFormat:tdm2}",
        "45/456/36":               "{:brailleFormat:tdm3}",
        "45/34":               "{:brailleFormat: ́}",
        "45/3456/1456":               "{:brailleFormat:tds4}",
        "45/346":               "{:brailleFormat: ̌}",
        "45/356":               "{:brailleFormat:”}",
        "456/2456":               "{:brailleFormat:world}",
        "456/256":               "{:brailleFormat:•}",
        "456/26":               "{:brailleFormat:ə}",
        "456/234":               "{:brailleFormat:spirit}",
        "456/2346":               "{:brailleFormat:their}",
        "456/236":               "{:brailleFormat:«}",
        "456/125":               "{:brailleFormat:had}",
        "456/126":               "{:brailleFormat:\{}",
        "456/14":               "{:brailleFormat:cannot}",
        "456/1456":               "{:brailleFormat:#}",
        "456/16":               "{:brailleFormat:\\}",
        "456/134":               "{:brailleFormat:many}",
        "456/34":               "{:brailleFormat:/}",
        "456/345":               "{:brailleFormat:\}}",
        "456/3456/1456":               "{:brailleFormat:tdf5}",
        "456/356":               "{:brailleFormat:»}",
        "46":               "{:brailleFormat:less}",
        "46/234":               "{:brailleFormat:less}",
        "46/2345":               "{:brailleFormat:ount}",
        "46/126":               "{:brailleFormat:[}",
        "46/145":               "{:brailleFormat:ound}",
        "46/15":               "{:brailleFormat:ance}",
        "46/1345":               "{:brailleFormat:sion}",
        "46/345":               "{:brailleFormat:]}",
        "46/356":               "{:brailleFormat:%}",
        "46/3456/1456":               "{:brailleFormat:tds7}",
        "5/2456":               "{:brailleFormat:work}",
        "5/234":               "{:brailleFormat:some}",
        "5/2345":               "{:brailleFormat:time}",
        "5/2346":               "{:brailleFormat:there}",
        "5/235":               "{:brailleFormat:+}",
        "5/2356":               "{:brailleFormat:=}",
        "5/236":               "{:brailleFormat:×}",
        "5/124":               "{:brailleFormat:father}",
        "5/125":               "{:brailleFormat:here}",
        "5/1256":               "{:brailleFormat:ought}",
        "5/126":               "{:brailleFormat:(}",
        "5/123":               "{:brailleFormat:lord}",
        "5/1234":               "{:brailleFormat:part}",
        "5/12345":               "{:brailleFormat:question}",
        "5/1235":               "{:brailleFormat:right}",
        "5/145":               "{:brailleFormat:day}",
        "5/1456":               "{:brailleFormat:through}",
        "5/15":               "{:brailleFormat:ever}",
        "5/156":               "{:brailleFormat:where}",
        "5/16":               "{:brailleFormat:character}",
        "5/13":               "{:brailleFormat:know}",
        "5/134":               "{:brailleFormat:mother}",
        "5/1345":               "{:brailleFormat:name}",
        "5/13456":               "{:brailleFormat:young}",
        "5/135":               "{:brailleFormat:one}",
        "5/136":               "{:brailleFormat:under}",
        "5/5/123456":               "{:brailleFormat:dlu}",
        "5/6/36":               "{:brailleFormat:——}",
        "5/34":               "{:brailleFormat:÷}",
        "5/345":               "{:brailleFormat:)}",
        "5/3456/1456":               "{:brailleFormat:tds6}",
        "5/35":               "{:brailleFormat:*}",
        "5/36":               "{:brailleFormat:−}",
        "56/135":               "{:brailleFormat:→}",
        "56/146":               "{:brailleFormat:↓}",
        "56/246":               "{:brailleFormat:←}",
        "56/346":               "{:brailleFormat:↑}",
        "56/24":               "{:brailleFormat:i}",
        "56/245":               "{:brailleFormat:j}",
        "56/2456":               "{:brailleFormat:w}",
        "56/234":               "{:brailleFormat:ness}",
        "56/2345":               "{:brailleFormat:ment}",
        "56/236":               "{:brailleFormat:?}",
        "56/1":               "{:brailleFormat:a}",
        "56/12":               "{:brailleFormat:b}",
        "56/124":               "{:brailleFormat:f}",
        "56/1245":               "{:brailleFormat:ong}",
        "56/125":               "{:brailleFormat:h}",
        "56/123":               "{:brailleFormat:ful}",
        "56/1234":               "{:brailleFormat:p}",
        "56/12345":               "{:brailleFormat:q}",
        "56/1235":               "{:brailleFormat:r}",
        "56/1236":               "{:brailleFormat:v}",
        "56/14":               "{:brailleFormat:c}",
        "56/145":               "{:brailleFormat:d}",
        "56/15":               "{:brailleFormat:ence}",
        "56/13":               "{:brailleFormat:k}",
        "56/134":               "{:brailleFormat:m}",
        "56/1345":               "{:brailleFormat:tion}",
        "56/13456":               "{:brailleFormat:ity}",
        "56/1346":               "{:brailleFormat:x}",
        "56/135":               "{:brailleFormat:o}",
        "56/1356":               "{:brailleFormat:z}",
        "56/136":               "{:brailleFormat:u}",
        "56/25":               "{:brailleFormat::}",
        "56/56":               "{plover:toggle_dict:+grade1.json}",
        "56/56/56":               "{plover:toggle_dict:+grade1-passage.json}",
        "56/6/24":               "{:brailleFormat:I}",
        "56/6/245":               "{:brailleFormat:J}",
        "56/6/2456":               "{:brailleFormat:W}",
        "56/6/234":               "{:brailleFormat:S}",
        "56/6/2345":               "{:brailleFormat:T}",
        "56/6/236":               "{:brailleFormat:?}",
        "56/6/1":               "{:brailleFormat:A}",
        "56/6/12":               "{:brailleFormat:B}",
        "56/6/124":               "{:brailleFormat:F}",
        "56/6/1245":               "{:brailleFormat:G}",
        "56/6/125":               "{:brailleFormat:H}",
        "56/6/123":               "{:brailleFormat:L}",
        "56/6/1234":               "{:brailleFormat:P}",
        "56/6/12345":               "{:brailleFormat:Q}",
        "56/6/1235":               "{:brailleFormat:R}",
        "56/6/1236":               "{:brailleFormat:V}",
        "56/6/14":               "{:brailleFormat:C}",
        "56/6/145":               "{:brailleFormat:D}",
        "56/6/15":               "{:brailleFormat:E}",
        "56/6/13":               "{:brailleFormat:K}",
        "56/6/134":               "{:brailleFormat:M}",
        "56/6/1345":               "{:brailleFormat:N}",
        "56/6/13456":               "{:brailleFormat:Y}",
        "56/6/1346":               "{:brailleFormat:X}",
        "56/6/135":               "{:brailleFormat:O}",
        "56/6/1356":               "{:brailleFormat:Z}",
        "56/6/136":               "{:brailleFormat:U}",
        "56/3":               "{:brailleFormat:g1t}",
        "6":               "{&}{-|}",
        "6/6":               "{plover:toggle_dict:+caps.json}",
        "6/6/6":               "{plover:toggle_dict:-caps.json}{mode:CAPS}",
        "6/3":               "{mode:RESET}",
        "6/2356":               "{:brailleFormat:\"}",
        "6/236":               "{:brailleFormat:‘}",
        "6/45/235":               "{:brailleFormat:ligature capital}",
        "6/45/1345":               "{:brailleFormat:Ŋ}",
        "6/456/26":               "{:brailleFormat:Ə}",
        "6/46/2456":               "{:brailleFormat:Ω}",
        "6/46/234":               "{:brailleFormat:Σ}",
        "6/46/2345":               "{:brailleFormat:Τ}",
        "6/46/1":               "{:brailleFormat:Α}",
        "6/46/12":               "{:brailleFormat:Β}",
        "6/46/124":               "{:brailleFormat:Φ}",
        "6/46/1245":               "{:brailleFormat:Γ}",
        "6/46/123":               "{:brailleFormat:Λ}",
        "6/46/1234":               "{:brailleFormat:Π}",
        "6/46/12346":               "{:brailleFormat:Χ}",
        "6/46/1235":               "{:brailleFormat:Ρ}",
        "6/46/14":               "{:brailleFormat:Ι}",
        "6/46/145":               "{:brailleFormat:Δ}",
        "6/46/1456":               "{:brailleFormat:Θ}",
        "6/46/15":               "{:brailleFormat:Ε}",
        "6/46/156":               "{:brailleFormat:Η}",
        "6/46/13":               "{:brailleFormat:Κ}",
        "6/46/134":               "{:brailleFormat:Μ}",
        "6/46/1345":               "{:brailleFormat:Ν}",
        "6/46/13456":               "{:brailleFormat:Ψ}",
        "6/46/1346":               "{:brailleFormat:Ξ}",
        "6/46/135":               "{:brailleFormat:Ο}",
        "6/46/1356":               "{:brailleFormat:Ζ}",
        "6/46/136":               "{:brailleFormat:Υ}",
        "6/5/126":               "{:brailleFormat:(}",
        "6/5/5":               "{:brailleFormat:ct}",
        "6/5/345":               "{:brailleFormat:)}",
        "6/356":               "{:brailleFormat:’}",
        "6/36":               "{:brailleFormat:—}",
        "3":               "{:brailleFormat:'}",
        "34":               "{:brailleFormat:st}",
        "345":               "{:brailleFormat:ar}",
        "3456":               "{plover:toggle_dict:+numbers.json,+grade1.json}",
        "346":               "{:brailleFormat:ing}",
        "35":               "{:brailleFormat:in}",
        "356":               "{:brailleFormat:”}",
        "36":               "{:brailleFormat:–}",
#        \u00a0
        #"4/16": "{& ̸}", # modifierSolidus
        "4/16": "{:brailleFormat:\u0338}", # modifierSolidus
        #"4/25": "{& ̵}", # modifierHorizontalStroke
        "4/25": "{:brailleFormat:\u0335}", # modifierHorizontalStroke
        #"4/346": "{& ̆}", # modifierBreve
        "4/346": "{:brailleFormat:\u0306}", # modifierBreve
        #"4/36": "{& ̄}", # modifierMacron
        "4/36": "{:brailleFormat:\u0304}", # modifierMacron
        #"45/12346": "{& ̧}", # modifierCedilla
        "45/12346": "{:brailleFormat:\u0327}", # modifierCedilla
        #"45/16": "{& ̀}", # modifierGrave
        "45/16": "{:brailleFormat:\u0300}", # modifierGrave
        #"45/146": "{& ̂}", # modifierCircumflex
        "45/146": "{:brailleFormat:\u0302}", # modifierCircumflex
        #"45/1246": "{& ̊}", # modifierRing
        "45/1246": "{:brailleFormat:\u030A}", # modifierRing
        #"45/12456": "{& ̃}", # modifierTilde
        "45/12456": "{:brailleFormat:\u0303}", # modifierTilde
        #"45/25": "{& ̈}", # modifierDiaeresis
        "45/25": "{:brailleFormat:\u0308}", # modifierDiaeresis
        #"45/34": "{& ́}", # modifierAcute
        "45/34": "{:brailleFormat:\u0301}", # modifierAcute
        #"45/346": "{& ̌}", # modifierCaron
        "45/346": "{:brailleFormat:\u030C}", # modifierCaron
        "LB": "{PLOVER:TOGGLE}",
        "LBS":               "{plover:priority_dict:numbers.json,grade1-passage.json,grade1.json,numbers.json,caps.json,braille.py,cell.py,brf.py}{plover:toggle_dict:-numbers.json,-grade1-passage.json,-grade1.json,-caps.json,+braille.py,-cell.py,-brf.py}",
        "L14B" : "{plover:toggle_dict:+cell.py,-braille.py}",
        "L12B" : "{plover:toggle_dict:+brf.py,-braille.py}"
}

def tr(letters):
    translateDict = {                            
            'f':               '1',                                    
            'd':               '2',                 
            's':               '3',                     
            'j':               '4',                      
            'k':               '5',                              
            'l':               '6', 
            'B':               'B',                                   
            'L':               'L',                                             
            'S':               'S',                                             
            }                                     
    ret = ''
    for l in letters:
        if l in translateDict:
            ret = ret + translateDict[l]
        else:
            ret = ret + l
    return ret

LONGEST_KEY = 10

def lookup(stroke):
    key = tr('/'.join(list(stroke)))
    disable = '{plover:toggle_dict:-numbers.json,-caps.json}'
    if key not in dictionary:
        if len(stroke) == 1 and stroke != ('B',):
            return '{&[' + stroke[0] + ']}'
        else:
            raise KeyError
    output = dictionary[key]
    dcmd = 'toggle_dict' in output
    if dcmd:
        return output
    else:
        return output + disable
