obliczanki.sql
1.95 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
-- nieadj to 20, 21, 22, 23
-- SGJP
SELECT
pos,
CASE WHEN l_id_od IS null THEN 'aff'
ELSE 'neg' END AS nie,
count(*)
FROM leksemy l LEFT OUTER JOIN odsylacze o
ON (l.id = o.l_id_od AND typods_id IN (20, 21, 22, 23))
WHERE slownik = 'SGJP'
GROUP BY pos, nie;
-- wspólne (złe! leksem się liczy tyle razy, ile razy jest w słowniku)
SELECT
pos,
CASE WHEN l_id_od IS null THEN 'aff'
ELSE 'neg' END AS nie,
count(*)
FROM leksemy l JOIN leksemy_w_slownikach s1
ON (l.id = s1.l_id)
JOIN leksemy_w_slownikach s2
ON (l.id = s2.l_id)
LEFT OUTER JOIN odsylacze o
ON (l.id = o.l_id_od AND typods_id IN (20, 21, 22, 23))
WHERE s1.slownik = 'SGJP' AND s2.slownik = 'Morfologik'
GROUP BY pos, nie;
-- razem
SELECT
pos,
CASE WHEN l_id_od IS null THEN 'aff'
ELSE 'neg' END AS nie,
count(*)
FROM leksemy l LEFT OUTER JOIN odsylacze o
ON (l.id = o.l_id_od AND typods_id IN (20, 21, 22, 23))
WHERE slownik IN ('SGJP', 'Morfologik')
GROUP BY pos, nie;
-- tylko Morfologik
SELECT
pos,
CASE WHEN l_id_od IS null THEN 'aff'
ELSE 'neg' END AS nie,
count(*)
FROM leksemy l LEFT OUTER JOIN odsylacze o
ON (l.id = o.l_id_od AND typods_id IN (20, 21, 22, 23))
WHERE slownik = 'Morfologik'
GROUP BY pos, nie;
-- tylko SGJP (wspólne bez not)
SELECT
pos,
CASE WHEN l_id_od IS null THEN 'aff'
ELSE 'neg' END AS nie,
count(*)
FROM leksemy l LEFT OUTER JOIN odsylacze o
ON (l.id = o.l_id_od AND typods_id IN (20, 21, 22, 23))
WHERE slownik = 'SGJP' AND NOT exists(SELECT
id
FROM leksemy_w_slownikach
WHERE l_id = l.id AND
slownik = 'Morfologik')
GROUP BY pos, nie;
-- Morfologik wg statusów
SELECT
pos,
status,
count(*)
FROM leksemy l
WHERE slownik = 'Morfologik'
GROUP BY pos, status
ORDER BY pos, status;