Coverage Report - orca.pronunciation_dict

ModuleCoverage %
orca.pronunciation_dict
73%
1
# Orca
2
#
3
# Copyright 2006 Sun Microsystems Inc.
4
#
5
# This library is free software; you can redistribute it and/or
6
# modify it under the terms of the GNU Library General Public
7
# License as published by the Free Software Foundation; either
8
# version 2 of the License, or (at your option) any later version.
9
#
10
# This library is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# Library General Public License for more details.
14
#
15
# You should have received a copy of the GNU Library General Public
16
# License along with this library; if not, write to the
17
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
# Boston, MA 02111-1307, USA.
19
20
"""Exposes a dictionary, pronunciation_dict, that maps words to what
21 1
they sound like."""
22
23 1
__id__        = "$Id: pronunciation_dict.py 1732 2006-11-22 15:56:10Z richb $"
24 1
__version__   = "$Revision: 1732 $"
25 1
__date__      = "$Date: 2006-11-22 07:56:10 -0800 (Wed, 22 Nov 2006) $"
26 1
__copyright__ = "Copyright (c) 2006 Sun Microsystems Inc."
27 1
__license__   = "LGPL"
28
29 1
from orca_i18n import _ # for gettext support
30
31
# pronunciation_dict is a dictionary where the keys are words and the 
32
# values represent word the pronunciation of that word (in other words, 
33
# what the word sounds like).
34
#
35
# [[[TODO: richb - need to populate this dictionary with many more values.]]]
36
#
37 1
pronunciation_dict = {}
38 1
pronunciation_dict[_("ASAP")]    = _("as soon as possible")
39 1
pronunciation_dict[_("GHz")]     = _("gigahertz")
40 1
pronunciation_dict[_("IMAP")]    = _("eye map")
41 1
pronunciation_dict[_("LDAP")]    = _("ell dap")
42 1
pronunciation_dict[_("LOL")]     = _("laughing out loud")
43 1
pronunciation_dict[_("MHz")]     = _("megahertz")
44 1
pronunciation_dict[_("strikethrough")] = _("strike through")
45 1
pronunciation_dict[_("SELinux")] = _("ess ee linux")
46
47 1
def getPronunciation(word):
48
    """Given a word, return a string that represents what this word
49
    sounds like.
50
51
    Arguments:
52
    - key: the word to get the "sounds like" representation for.
53
54
    Returns a string that represents what this word sounds like, or 
55
    the word if there is no representation.
56
    """
57
58 0
    if isinstance(word, unicode):
59 0
        word = word.encode("UTF-8")
60
61 0
    try:
62 0
        return pronunciation_dict[word]
63 0
    except:
64 0
        return word