-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlevel3_rules.py
33 lines (26 loc) · 1011 Bytes
/
level3_rules.py
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
import grammar
import random
# association rules using description logics
# level 1: article + property + object
# level 2: article + property + object + preposition + object
# level 3: article + property + object + preposition + article + property + object
art = ''
head1 = []
head2 = []
with open("level3.txt", "w") as level3_file, open("level1.txt", "r") as level1_file:
level1_file_lines = level1_file.readlines()
for i in range(50):
if i % 2 == 0:
head1.append(random.choice(level1_file_lines)[:-1])
# head1[i] = head1[i][:-1]
for j in range(60, 99):
if j % 2 == 0:
head2.append(random.choice(level1_file_lines)[:-1])
# head2[j] = head2[j][:-1]
def dl_level3():
for i in range(600):
level3_file.write((random.choice(head1) + " " +
random.choice(grammar.prepositions) + " " +
random.choice(head2)))
level3_file.write("\n")
dl_level3()