-
Notifications
You must be signed in to change notification settings - Fork 0
/
trigrams-limited.txt
65 lines (65 loc) · 2.43 KB
/
trigrams-limited.txt
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
WITH raw_trigram_data AS
(
SELECT
key_code,
lag(key_code) OVER (ORDER BY time_utc) AS key_code_lag_1,
lag(key_code, 2) OVER (ORDER BY time_utc) AS key_code_lag_2
FROM key_log
)
, trigram_counts AS
(
SELECT
key_code_lag_2 || ' ' || key_code_lag_1 || ' ' || key_code AS trigram,
count(*) AS count
FROM raw_trigram_data
WHERE true
AND key_code IS NOT NULL
AND key_code_lag_1 IS NOT NULL
AND key_code_lag_2 IS NOT NULL
AND key_code NOT LIKE '%+%'
AND key_code_lag_1 NOT LIKE '%+%'
AND key_code_lag_2 NOT LIKE '%+%'
AND key_code NOT LIKE '%<enter>%'
AND key_code_lag_1 NOT LIKE '%<enter>%'
AND key_code_lag_2 NOT LIKE '%<enter>%'
AND key_code NOT LIKE '%<space>%'
AND key_code_lag_1 NOT LIKE '%<space>%'
AND key_code_lag_2 NOT LIKE '%<space>%'
AND key_code NOT LIKE '%<backspace>%'
AND key_code_lag_1 NOT LIKE '%<backspace>%'
AND key_code_lag_2 NOT LIKE '%<backspace>%'
AND key_code NOT LIKE '%<media_volume_up>%'
AND key_code_lag_1 NOT LIKE '%<media_volume_up>%'
AND key_code_lag_2 NOT LIKE '%<media_volume_up>%'
AND key_code NOT LIKE '%<media_volume_down>%'
AND key_code_lag_1 NOT LIKE '%<media_volume_down>%'
AND key_code_lag_2 NOT LIKE '%<media_volume_down>%'
AND key_code NOT LIKE '%<left>%'
AND key_code_lag_1 NOT LIKE '%<left>%'
AND key_code_lag_2 NOT LIKE '%<left>%'
AND key_code NOT LIKE '%<right>%'
AND key_code_lag_1 NOT LIKE '%<right>%'
AND key_code_lag_2 NOT LIKE '%<right>%'
AND key_code NOT LIKE '%<up>%'
AND key_code_lag_1 NOT LIKE '%<up>%'
AND key_code_lag_2 NOT LIKE '%<up>%'
AND key_code NOT LIKE '%<down>%'
AND key_code_lag_1 NOT LIKE '%<down>%'
AND key_code_lag_2 NOT LIKE '%<down>%'
AND key_code NOT LIKE '%<tab>%'
AND key_code_lag_1 NOT LIKE '%<tab>%'
AND key_code_lag_2 NOT LIKE '%<tab>%'
GROUP BY 1
)
, trigram_frequencies AS
(
SELECT *,
(1.0* count ) / (SELECT sum(count) FROM trigram_counts) AS frequency
FROM trigram_counts
)
SELECT *, SUM(frequency) OVER (
ORDER BY frequency DESC ROWS UNBOUNDED PRECEDING
) AS cumulative_frequency
FROM trigram_frequencies
GROUP BY trigram
ORDER BY cumulative_frequency, count DESC, trigram