1 """Chord type mappings
2
3 Chord supertaggers use mappings from the input chord vocabulary to a smaller
4 one. Various mappings are available and may be selected at model training
5 time.
6
7 """
8 """
9 ============================== License ========================================
10 Copyright (C) 2008, 2010-12 University of Edinburgh, Mark Granroth-Wilding
11
12 This file is part of The Jazz Parser.
13
14 The Jazz Parser is free software: you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 The Jazz Parser is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with The Jazz Parser. If not, see <http://www.gnu.org/licenses/>.
26
27 ============================ End license ======================================
28
29 """
30 __author__ = "Mark Granroth-Wilding <mark.granroth-wilding@ed.ac.uk>"
31
32 from jazzparser.utils.options import ModuleOption, choose_from_dict
33
34 NAMED_MAPPINGS = {}
35
37 """
38 Just a dictionary with a name.
39 """
40 - def __init__(self, name, *args, **kwargs):
43
44
45 SMALL_MAPPING = NamedMapping("small", {
46 "" : "",
47 "m" : "m",
48 "M7" : "",
49 "o7" : "o7",
50 "%7" : "o7",
51 "aug" : "aug",
52 "m,b5" : "o7",
53 "b5" : "7",
54 "m,M7" : "m",
55 "7" : "7",
56 "m7" : "m7",
57 "aug7" : "aug",
58 "b5,7" : "7",
59 "sus4" : "",
60 "sus4,7" : "7",
61 "aug,M7" : "aug",
62 "b5,M7" : "7",
63 "#5,m7" : "m7",
64 })
65
66
67 BIG_MAPPING = NamedMapping("big", {
68 "" : "",
69 "m" : "m",
70 "M7" : "M7",
71 "o7" : "o7",
72 "%7" : "o7",
73 "aug" : "aug",
74 "m,b5" : "o7",
75 "b5" : "b5",
76 "m,M7" : "m",
77 "7" : "7",
78 "m7" : "m7",
79 "aug7" : "aug7",
80 "b5,7" : "7",
81 "sus4" : "sus4",
82 "sus4,7" : "sus4",
83 "aug,M7" : "aug",
84 "b5,M7" : "7",
85 "#5,m7" : "m7",
86 })
87
88
89 IDENTITY_MAPPING = NamedMapping("none", {
90 "" : "",
91 "m" : "m",
92 "M7" : "M7",
93 "o7" : "o7",
94 "%7" : "%7",
95 "aug" : "aug",
96 "m,b5" : "m,b5",
97 "b5" : "b5",
98 "m,M7" : "m,M7",
99 "7" : "7",
100 "m7" : "m7",
101 "aug7" : "aug7",
102 "b5,7" : "b5,7",
103 "sus4" : "sus4",
104 "sus4,7" : "sus4,7",
105 "aug,M7" : "aug,M7",
106 "b5,M7" : "b5,M7",
107 "#5,m7" : "#5,m7",
108 })
109
110 NAMED_MAPPINGS = dict([(mapping.name, mapping) for mapping in \
111 [
112 SMALL_MAPPING,
113 IDENTITY_MAPPING,
114 BIG_MAPPING,
115 ]
116 ])
117 MAPPINGS = NAMED_MAPPINGS.keys()
118 DEFAULT_MAPPING = "small"
119
121 """
122 Returns a dictionary chord type mapping identified by its name.
123 A list of available mappings can be found in L{MAPPINGS}.
124
125 """
126 if name is None:
127 name = DEFAULT_MAPPING
128 return NAMED_MAPPINGS[name]
129
138