File size: 639 Bytes
45ca953
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import random
keywords=[]
with open('keywords.txt',encoding='utf-8') as f:
    for key in f.read().split():
        keywords.append(key)

with open('sel.txt',encoding='utf-8') as f:
    text=f.read()

#generate questions about keywords in text
lines = text.split('\n')

random.shuffle(lines)

def make_question(key,line):
    pos = line.rfind(key)
    if pos == -1:
        return None
    line = line[:pos] + '__'
    return line

for line in lines[:100]:
    line = line.strip()
    for key in keywords:
        if key in line:
            #print(make_question(key,line))
            print(line)
            print(key)
            break