-
Notifications
You must be signed in to change notification settings - Fork 0
/
rules.datalog
36 lines (30 loc) · 1018 Bytes
/
rules.datalog
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
top_words_starting_with[word, prefix, text_id, count] :=
*Word{ word, count, text_id },
prefix[prefix],
starts_with(word, prefix)
texts_with_word_starting_with[text_id, word, count, url, prefix] :=
*Text{ text_id, url },
*Word{ word, text_id , count},
prefix[prefix],
starts_with(word, prefix)
words_ending_with[word, suffix, text_id, count] :=
*Word{ word, count, text_id },
suffix[suffix],
ends_with(word, suffix)
texts_with_word_ending_with[text_id, word, count, url, suffix] :=
*Text{ text_id, url },
*Word{ word, text_id, count },
suffix[suffix],
ends_with(word, suffix)
words_containing[word, substr, text_id, count] :=
*Word{ word, count, text_id },
substring[substr],
str_includes(word, substr)
texts_containing[text_id, substr, url] :=
*Text{ text_id, url, text },
substring[substr],
str_includes(text, substr)
word_ends[word, suffix, text_id] :=
*Word{ word, text_id },
suffix[suffix],
ends_with(word, suffix)