-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapplication.conf
More file actions
185 lines (163 loc) · 6.18 KB
/
application.conf
File metadata and controls
185 lines (163 loc) · 6.18 KB
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
179
180
181
182
183
184
deepdive {
sampler.sampler_args: "-l 300 -s 1 -i 500 --alpha 0.1 -c 0"
schema.variables {
locations.is_correct: Boolean
}
pipeline.run: all
pipeline.pipelines {
preprocess = [ extract_preprocess ]
entity_features_only = [ extract_pairs, one_of_n_features, consecutive_in_proximity,
city, city_with_hundreds_of_thousands_of_inhabitants, city_with_millions_of_inhabitants ]
all_features = [ extract_pairs, extract_context_features, one_of_n_features, consecutive_in_proximity,
city, city_with_hundreds_of_thousands_of_inhabitants, city_with_millions_of_inhabitants, context_features ]
all = [ extract_preprocess, extract_pairs, extract_context_features, one_of_n_features, consecutive_in_proximity,
city, city_with_hundreds_of_thousands_of_inhabitants, city_with_millions_of_inhabitants, context_features ]
}
db.default {
driver : "org.postgresql.Driver"
url : "jdbc:postgresql://"${PGHOST}":"${PGPORT}"/"${DBNAME}
user : ${PGUSER}
password : ${PGPASSWORD}
dbname : ${DBNAME}
host : ${PGHOST}
port : ${PGPORT}
gphost : ${GPHOST}
gpport : ${GPPORT}
gppath : ${GPPATH}
# start gpfdist server on the machine running the application with
# `rungpcommand 'gpfdist -d /lfs/raiders4/0/rionda/greenplum_gpfdist-memex -p 9999'`
}
calibration.holdout_fraction: 0.075
extraction.extractors {
extract_preprocess: {
style: json_extractor
before: psql -h ${PGHOST} -p ${PGPORT} -d ${DBNAME} -f ${APP_HOME}/schemas/sentences.sql
input: """
SELECT id,
body
FROM articles
WHERE NOT BODY IS NULL
ORDER BY id ASC
"""
output_relation: sentences
udf: ${DEEPDIVE_HOME}/examples/nlp_extractor/run.sh -k id -v body -l 100 -t 16 -a "tokenize,ssplit,pos"
}
extract_pairs: {
style: tsv_extractor
before: psql -h ${PGHOST} -p ${PGPORT} -d ${DBNAME} -f ${APP_HOME}/schemas/locations.sql
input: """
SELECT
sentence_id,
array_to_string(words, ' '),
array_to_string(pos_tags, ' ')
FROM sentences;
"""
output_relation: locations
udf: ${APP_HOME}/udf/extract_pairs.py
}
extract_context_features: {
style: tsv_extractor
before: psql -h ${PGHOST} -p ${PGPORT} -d ${DBNAME} -f ${APP_HOME}/schemas/context_features.sql
input: """
SELECT
l.sentence_id, mention_num, w_from, w_to,
array_to_string(words, ' '),
array_to_string(pos_tags, ' ')
FROM sentences s, (SELECT DISTINCT sentence_id, mention_num, w_from, w_to FROM locations) l
WHERE s.sentence_id = l.sentence_id;
"""
output_relation: context_features
udf: ${APP_HOME}/udf/extract_context_features.py
}
supervise: {
style: tsv_extractor
input: """
SELECT
FROM sentences
"""
output_relation: locations
udf: ${APP_HOME}/udf/supervise.py
}
}
inference.factors {
one_of_n_features {
input_query = """
SELECT l1.id as "linking1.id", l1.is_correct as "linking1.is_correct",
l2.id as "linking2.id", l2.is_correct as "linking2.is_correct"
FROM locations l1, locations l2
WHERE l1.sentence_id = l2.sentence_id
AND l1.mention_num = l2.mention_num
AND NOT l1.mention_id = l2.mention_id;
"""
function: "And(linking1.is_correct, linking2.is_correct)"
weight: -10
}
# prefer if subsequently mentioned cities are within 1000km distance
consecutive_in_proximity {
input_query: """
SELECT l1.id as "linking1.id", l1.is_correct as "linking1.is_correct",
l2.id as "linking2.id", l2.is_correct as "linking2.is_correct"
FROM locations l1, locations l2,
wikidata_coordinate_locations c1, wikidata_coordinate_locations c2
WHERE l1.loc_id = c1.item_id
AND l2.loc_id = c2.item_id
AND l1.sentence_id = l2.sentence_id
AND l2.mention_num = l1.mention_num + 1
AND earth_distance(ll_to_earth(c1.latitude,c1.longitude), ll_to_earth(c2.latitude,c2.longitude)) < 1000;
"""
function: "And(linking1.is_correct, linking2.is_correct)"
weight: "3"
}
# prefer larger cities
city {
input_query: """
SELECT l.id as "linking.id", l.is_correct as "linking.is_correct"
FROM locations l, wikidata_instanceof i
WHERE l.loc_id = i.item_id
AND i.clazz_id = 515;
"""
function: "IsTrue(linking.is_correct)"
weight: 1
}
city_with_hundreds_of_thousands_of_inhabitants {
input_query: """
SELECT l.id as "linking.id", l.is_correct as "linking.is_correct"
FROM locations l, wikidata_instanceof i
WHERE l.loc_id = i.item_id
AND i.clazz_id = 1549591;
"""
function: "IsTrue(linking.is_correct)"
weight: 1
}
city_with_millions_of_inhabitants {
input_query: """
SELECT l.id as "linking.id", l.is_correct as "linking.is_correct"
FROM locations l, wikidata_instanceof i
WHERE l.loc_id = i.item_id
AND i.clazz_id = 1637706;
"""
function: "IsTrue(linking.is_correct)"
weight: 1
}
boost_countries {
input_query: """
SELECT l.id as "linking.id", l.is_correct as "linking.is_correct"
FROM locations l, wikidata_instanceof i
WHERE l.loc_id = i.item_id
AND i.clazz_id = 6256;
"""
function: "IsTrue(linking.is_correct)"
weight: 3
}
context_features {
input_query = """
SELECT l.id as "locations.id", l.is_correct as "locations.is_correct", unnest(f.features) as "locations.feature"
FROM locations l, context_features f
WHERE l.sentence_id = f.sentence_id
AND l.mention_num = f.mention_num;
"""
function: "IsTrue(locations.is_correct)"
weight: "?(locations.feature)"
}
}
}