Skip to content
This repository was archived by the owner on May 30, 2025. It is now read-only.

Commit f0455ef

Browse files
committed
Changing data folder structure
1 parent ec06257 commit f0455ef

34 files changed

+556
-20
lines changed

score.py renamed to score_test.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ def update(dict_1, dict_2):
8181
submit = os.path.join(sys.argv[1], 'res')
8282
output = sys.argv[2]
8383
else:
84-
gold = 'gold'
85-
submit = 'submit'
84+
print('(!) Using `trial/submit` as test files and `trial/gold` as reference files.')
85+
gold = 'trial/gold'
86+
submit = 'trial/submit'
8687
output = '.'
8788

8889
totals1 = collections.defaultdict(lambda: 0)
@@ -102,9 +103,9 @@ def update(dict_1, dict_2):
102103
scenario3 = evaluate_3(name, gold, submit)
103104
update(scenario3, totals3)
104105

105-
pprint.pprint(('Scenario 1', totals1))
106-
pprint.pprint(('Scenario 2', totals2))
107-
pprint.pprint(('Scenario 3', totals3))
106+
# pprint.pprint(('Scenario 1', totals1))
107+
# pprint.pprint(('Scenario 2', totals2))
108+
# pprint.pprint(('Scenario 3', totals3))
108109

109110
correct_1 = sum([totals1['correct_A'], totals1['correct_B'], totals1['correct_C'], 0.5 * totals1['partial_A']])
110111
subtotal_1 = sum([totals1['partial_A'], totals1['correct_A'], totals1['correct_B'], totals1['incorrect_B'], totals1['correct_C']])
@@ -129,6 +130,17 @@ def update(dict_1, dict_2):
129130

130131
macro = sum([abc_f1, bc_f1, c_f1]) / 3
131132

133+
print('abc_prec:%.5f' % abc_prec)
134+
print('abc_rec:%.5f' % abc_rec)
135+
print('abc_f1:%.5f' % abc_f1)
136+
print('bc_prec:%.5f' % bc_prec)
137+
print('bc_rec:%.5f' % bc_rec)
138+
print('bc_f1:%.5f' % bc_f1)
139+
print('c_prec:%.5f' % c_prec)
140+
print('c_rec:%.5f' % c_rec)
141+
print('c_f1:%.5f' % c_f1)
142+
print('macro:%.5f' % macro)
143+
132144
with open(os.path.join(output, 'scores.txt'), 'w') as fp:
133145
fp.write('abc_prec:%.5f\n'% abc_prec)
134146
fp.write('abc_rec:%.5f\n' % abc_rec)

evaluate.py renamed to score_training.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,10 @@ def evaluate_links(gold_links_file, dev_links_file, sentences, gold_phrases, dev
167167
print("F1: %.2f" % f1)
168168

169169

170-
def evaluate(file):
171-
gold = sys.argv[1] if len(sys.argv) > 1 else "gold"
172-
dev = sys.argv[2] if len(sys.argv) > 2 else "dev"
173-
174-
input_file = abspath(join(gold, 'input_%s.txt' % file))
175-
gold_phrases_file = abspath(join(gold, 'output_A_%s.txt' % file))
176-
dev_phrases_file = abspath(join(dev, 'output_A_%s.txt' % file))
170+
def evaluate(file, folder):
171+
input_file = abspath(join(folder, 'input', 'input_%s.txt' % file))
172+
gold_phrases_file = abspath(join(folder, 'gold', 'output_A_%s.txt' % file))
173+
dev_phrases_file = abspath(join(folder, 'dev', 'output_A_%s.txt' % file))
177174

178175
if not exists(input_file):
179176
raise ValueError("Input file '%s' not found." % input_file)
@@ -186,8 +183,8 @@ def evaluate(file):
186183

187184
l = evaluate_phrases(input_file, gold_phrases_file, dev_phrases_file)
188185

189-
gold_labels_file = abspath(join(gold, 'output_B_%s.txt' % file))
190-
dev_labels_file = abspath(join(dev, 'output_B_%s.txt' % file))
186+
gold_labels_file = abspath(join(folder, 'gold', 'output_B_%s.txt' % file))
187+
dev_labels_file = abspath(join(folder, 'dev', 'output_B_%s.txt' % file))
191188

192189
if not exists(gold_labels_file):
193190
raise ValueError("Gold phrases file '%s' not found." % gold_phrases_file)
@@ -197,8 +194,8 @@ def evaluate(file):
197194
else:
198195
evaluate_labels(gold_labels_file, dev_labels_file, *l)
199196

200-
ref_links_file = abspath(join(gold, 'output_C_%s.txt' % file))
201-
eval_links_file = abspath(join(dev, 'output_C_%s.txt' % file))
197+
ref_links_file = abspath(join(folder, 'gold', 'output_C_%s.txt' % file))
198+
eval_links_file = abspath(join(folder, 'dev', 'output_C_%s.txt' % file))
202199

203200
if not exists(eval_links_file):
204201
print("\n(!) Skipping Task C: file '%s' not found. Assuming task is not completed yet." % eval_links_file)
@@ -207,9 +204,8 @@ def evaluate(file):
207204

208205

209206
if __name__ == '__main__':
210-
gold = sys.argv[1] if len(sys.argv) > 1 else "gold"
211-
dev = sys.argv[2] if len(sys.argv) > 2 else "dev"
207+
folder = sys.argv[1] if len(sys.argv) > 1 else "training"
212208

213-
for fname in os.listdir(gold):
209+
for fname in os.listdir(os.path.join(folder, 'input')):
214210
if fname.startswith("input_"):
215-
evaluate(fname[6:-4])
211+
evaluate(fname[6:-4], folder)

test/submit/scenario2-BC/.gitkeep

Whitespace-only changes.

test/submit/scenario3-C/.gitkeep

Whitespace-only changes.

training/dev/.gitkeep

Whitespace-only changes.

training/gold/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)