-
Notifications
You must be signed in to change notification settings - Fork 5
/
templates.py
178 lines (160 loc) · 4.1 KB
/
templates.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# -*- coding: utf-8 -*-
"""
A set of custom query DSL templates for elasticsearch search post-json requests for various tasks
Check elasticsearch documentation for more details
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html
Albin Andrew Correya
R&D Intern
@2017
"""
import os
assert os.environ["MSDES_HOST"]
assert os.environ["MSDES_PORT"]
assert os.environ["MSDES_INDEX"]
assert os.environ["MSDES_TYPE"]
SCHEME = "http"
URI = os.environ["MSDES_HOST"]
PORT = os.environ["MSDES_PORT"]
ES_INDEX = os.environ["MSDES_INDEX"]
ES_TYPE = os.environ["MSDES_TYPE"]
uri_config = {
'host': URI,
'port': PORT,
'scheme': SCHEME,
'index': ES_INDEX,
'type': ES_TYPE
}
# for string search with song title
# https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html
query_string = {
"query": {
"bool": {
"must": [
{
"query_string": {
"default_field": "msd_title",
"query": "sample_query_here"
}
}
],
"must_not": [
{
"query_string": {
"default_field": "_id",
"query": "msd_track_id_here"
}
}
]
}
},
"from": 0,
"size": 100
}
# for string search with title
# https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html
simple_query_string = {
"query": {
"bool": {
"must": [
{
"simple_query_string": {
"fields": ["msd_title"],
"query": "sample_query_here"
}
}
],
"must_not": [
{
"query_string": {
"default_field": "_id",
"query": "msd_track_id_here"
}
}
]
}
},
"from": 0,
"size": 100
}
# for lyrics search
# https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html
more_like_this = {
"query": {
"bool": {
"must": [
{
"more_like_this": {
"fields": ["dzr_lyrics.content"],
"like": "sample_query_here",
"min_term_freq": 1,
"max_query_terms": 12
}
}
],
"must_not": [
{
"query_string": {
"default_field": "_id",
"query": "msd_track_id_here"
}
}
]
}
},
"from": 0,
"size": 100
}
# config preset for logs
log_config = {
'method':
{
'query_method': 'title_query_with_artist_rerank',
'mode': 'msd_field',
'size': 100,
'dataset': 'shs_train'
},
'metrics':
{
'MAP': 0.,
'MRFC': 0.,
'MPER': 40.
},
'run_time': 60
}
# Experiment profiles
# SHS against MSD experiment
shs_msd = {
'dzr_map': False,
'filter_duplicates': False,
'shs_mode': False
}
# SHS against MSD experiment by excluding all the official duplicates
shs_msd_no_dup = {
'dzr_map': False,
'filter_duplicates': True,
'shs_mode': False
}
# SHS-DZR against MSD-DZR experiment by excluding all the official duplicates
shs_dzr_msd = {
'dzr_map': True,
'filter_duplicates': True,
'shs_mode': False
}
# SHS train set against SHS train set experiment
shs_shs = {
'dzr_map': False,
'filter_duplicates': False,
'shs_mode': True
}
# SHS train set against SHS train set experiment without official duplicates.
shs_shs_no_dup = {
'dzr_map': False,
'filter_duplicates': True,
'shs_mode': True
}
output_evaluations = {
'size': 100,
'map': 0,
'method': 'title',
'experiment': 'shs_msd',
}