forked from ondrejklejch/MT-ComparEval
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.sql
134 lines (113 loc) · 4.37 KB
/
schema.sql
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
CREATE TABLE "experiments" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" text NOT NULL,
"url_key" text NOT NULL UNIQUE,
"description" text NOT NULL,
"visible" integer DEFAULT 0
);
CREATE TABLE "sentences" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"experiments_id" integer NOT NULL,
"source" text NOT NULL,
"reference" text NOT NULL,
FOREIGN KEY ("experiments_id") REFERENCES "experiments" ("id") ON DELETE CASCADE
);
CREATE TABLE "tasks" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"experiments_id" integer NOT NULL,
"name" text NOT NULL,
"url_key" text NOT NULL,
"description" text NULL,
"visible" integer DEFAULT 0,
FOREIGN KEY ("experiments_id") REFERENCES "experiments" ("id") ON DELETE CASCADE,
UNIQUE("experiments_id","url_key")
);
CREATE TABLE "translations" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"tasks_id" integer NOT NULL,
"sentences_id" integer NOT NULL,
"text" text NOT NULL,
FOREIGN KEY ("tasks_id") REFERENCES "tasks" ("id") ON DELETE CASCADE,
FOREIGN KEY ("sentences_id") REFERENCES "sentences" ("id") ON DELETE CASCADE
);
CREATE TABLE "metrics" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" text NOT NULL
);
INSERT INTO "metrics" ("name") VALUES ("BLEU");
INSERT INTO "metrics" ("name") VALUES ("BLEU-cis");
INSERT INTO "metrics" ("name") VALUES ("PRECISION");
INSERT INTO "metrics" ("name") VALUES ("PRECISION-cis");
INSERT INTO "metrics" ("name") VALUES ("RECALL");
INSERT INTO "metrics" ("name") VALUES ("RECALL-cis");
INSERT INTO "metrics" ("name") VALUES ("F-MEASURE");
INSERT INTO "metrics" ("name") VALUES ("F-MEASURE-cis");
CREATE TABLE "translations_metrics" (
"translations_id" integer NOT NULL,
"metrics_id" integer NOT NULL,
"score" real NOT NULL,
FOREIGN KEY ("translations_id") REFERENCES "translations" ("id") ON DELETE CASCADE,
FOREIGN KEY ("metrics_id") REFERENCES "metrics" ("id") ON DELETE CASCADE
);
CREATE TABLE "tasks_metrics" (
"tasks_id" integer NOT NULL,
"metrics_id" integer NOT NULL,
"score" real NOT NULL,
FOREIGN KEY ("tasks_id") REFERENCES "tasks" ("id") ON DELETE CASCADE,
FOREIGN KEY ("metrics_id") REFERENCES "metrics" ("id") ON DELETE CASCADE
);
CREATE TABLE "tasks_metrics_samples" (
"tasks_id" integer NOT NULL,
"metrics_id" integer NOT NULL,
"sample_position" integer NOT NULL,
"score" real NOT NULL,
FOREIGN KEY ("tasks_id") REFERENCES "tasks" ("id") ON DELETE CASCADE,
FOREIGN KEY ("metrics_id") REFERENCES "metrics" ("id") ON DELETE CASCADE
);
CREATE TABLE "confirmed_ngrams" (
"translations_id" integer NOT NULL,
"text" text NOT NULL,
"length" integer NOT NULL,
"position" integer NOT NULL,
FOREIGN KEY ("translations_id") REFERENCES "translations" ("id") ON DELETE CASCADE
);
CREATE TABLE "unconfirmed_ngrams" (
"translations_id" integer NOT NULL,
"text" text NOT NULL,
"length" integer NOT NULL,
"position" integer NOT NULL,
FOREIGN KEY ("translations_id") REFERENCES "translations" ("id") ON DELETE CASCADE
);
CREATE TRIGGER delete_tasks_in_experiment AFTER DELETE ON experiments
FOR EACH ROW BEGIN
DELETE FROM tasks WHERE tasks.experiments_id = OLD.id;
END;
CREATE TRIGGER delete_sentences_in_experiment BEFORE DELETE ON experiments
FOR EACH ROW BEGIN
DELETE FROM sentences WHERE sentences.experiments_id = OLD.id;
END;
CREATE TRIGGER delete_translations_in_task BEFORE DELETE ON tasks
FOR EACH ROW BEGIN
DELETE FROM translations WHERE translations.tasks_id = OLD.id;
END;
CREATE TRIGGER delete_metrics_for_task BEFORE DELETE ON tasks
FOR EACH ROW BEGIN
DELETE FROM tasks_metrics WHERE tasks_metrics.tasks_id = OLD.id;
END;
CREATE TRIGGER delete_metrics_samples_for_task BEFORE DELETE ON tasks
FOR EACH ROW BEGIN
DELETE FROM tasks_metrics_samples WHERE tasks_metrics_samples.tasks_id = OLD.id;
END;
CREATE TRIGGER delete_metrics_for_translation BEFORE DELETE ON translations
FOR EACH ROW BEGIN
DELETE FROM translations_metrics WHERE translations_metrics.translations_id = OLD.id;
END;
CREATE TRIGGER delete_confirmed_ngrams_for_translation BEFORE DELETE ON translations
FOR EACH ROW BEGIN
DELETE FROM confirmed_ngrams WHERE confirmed_ngrams.translations_id = OLD.id;
END;
CREATE TRIGGER delete_unconfirmed_ngrams_for_translation BEFORE DELETE ON translations
FOR EACH ROW BEGIN
DELETE FROM unconfirmed_ngrams WHERE unconfirmed_ngrams.translations_id = OLD.id;
END;
--