-
Notifications
You must be signed in to change notification settings - Fork 0
/
messages.py
148 lines (115 loc) · 4.32 KB
/
messages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import logging
from varname import nameof
from constants import (
AUDIO_TYPES,
CREATE_INDEX,
FILE_TYPE_EXTENSIONS,
INDEX_TYPES,
SERIALIZE_PITCH_VECTORS,
SERIALIZE_OPTIONS,
MATCHING_ALGORITHMS,
MANHATTAN_DISTANCE,
METHODS
)
def log_bare_exception_error(err):
message = 'A unexpected problem occured.'
logging.error(err)
logging.error(message)
def log_could_not_calculate_mrr_warning(query_name):
message = " ".join([
f"Could not calculate Mean Reciprocal Ranking for \"{query_name}\",",
"because correct result was not found among candidates."
])
logging.warn(message)
def log_forgotten_step_warn(error, audio_type):
message = " ".join([
f"{error}.\n Hint: \nYou may have forgotten to perform {audio_type} "
"tfidf calculation step before."
])
logging.warn(message)
def log_impossible_serialize_option_error():
message = " ".join([
"You must inform at least one of serialization options",
SERIALIZE_OPTIONS
])
logging.error(message)
def log_invalid_audio_type_error(audio_type):
message = ' '.join([
f"'{audio_type}' is not a valid audio type.",
f"Options are {AUDIO_TYPES}."
])
logging.error(message)
def log_invalid_axes_number_error(axes_count, matching_algorithm_count):
message = " ".join([
f"{axes_count} axes number is invalid for {matching_algorithm_count}",
"matching algorithms. Try to inform the same number of axes of",
"matching algorithms or use only one axe."
])
logging.error(message)
def log_invalid_index_type_error(index_types):
message = ' '.join([
f"'{index_types}' is(are) not (a) valid index(es) type(s).",
f"Options are {INDEX_TYPES}."
])
logging.error(message)
def log_invalid_matching_algorithm_error(matching_algorithm):
if matching_algorithm == MANHATTAN_DISTANCE:
reason_message = f"{MANHATTAN_DISTANCE} is invalid in LSH search context. Use this only for TF-IDF."
else:
reason_message = f"Value '{matching_algorithm}' for matching algorithm is invalid."
message = ' '.join([
reason_message,
f"Valid algorithms are: {MATCHING_ALGORITHMS}."
])
logging.error(message)
def log_invalid_method_error(method_name):
message = f"Method '{method_name}' is invalid. Valid methods are: {METHODS}."
logging.error(message)
def log_no_confidence_measurement_found_error():
message = ' '.join([
'Confidence measurement file was not found.',
'Train confidence measurement first. Example usage:',
"'python main.py search_all --train_confidence true'"
])
logging.error(message)
def log_no_dumped_files_error(original_error):
message = ' '.join([
"ERROR: Couldn't load inverted index or audio mapping.",
"Are they dumped as files at all?",
f"Use method '{CREATE_INDEX}'",
"to generate the inverted index and audio mapping first."
])
logging.error(original_error)
logging.error(message)
def log_no_serialized_pitch_contour_segmentations_error(structure_name):
message = ' '.join([
f"ERROR: Couldn't load {structure_name}.",
f"Use method '{SERIALIZE_PITCH_VECTORS}',",
"to serialize pitch vectors first."
])
logging.error(message)
def log_seconds_not_found_warn(song_name, note_name, pitch):
message = " ".join([
f"{song_name}: Second was not found for note {note_name}",
f"(pitch, {pitch}). Assuming value as None.",
"You will need to filter out these none values if you try to use NLSH",
"indexing and searching. Remember to fix onsets too."
])
logging.warn(message)
def log_unsupported_file_extension_error(audio_path, extension):
message = " ".join([
f" '{audio_path}' has an unsupported file extension '{extension}'.",
f"Valid extensions are {FILE_TYPE_EXTENSIONS}"
])
logging.error(message)
def log_useless_arg_warn(arg, purpose):
arg_name = nameof(arg)
message = f"The argument '{arg_name}' is useless for {purpose}"
logging.warn(message)
def log_wrong_confidence_measurement_error(value):
message = ' '.join([
f'Value {value} of type {type(value)} is not a valid',
'confidence measurement value.',
'Expected type <float> .'
])
logging.error(message)