svjack commited on
Commit
324d529
1 Parent(s): 1c21a23

Upload en_t2t_model.py

Browse files
Files changed (1) hide show
  1. en_t2t_model.py +30 -0
en_t2t_model.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import text2text as t2t
2
+ from tqdm import tqdm
3
+
4
+ eng_context = '''
5
+ a petition dated 14th August, 2o05 for administrative review with the Director General, Inland Revenue Department.The Director General vide his Order dated 17th January, 2006 rejected the said petition. SNPL thereafter filed an appeal to the Revenue Tribunal, which refused to entertain the appeal in the absence of a pre-deposit of the entire
6
+ '''
7
+ t2t.Handler(["{} [SEP] {}".format(eng_context, "SNPL")], src_lang='en').question()
8
+ '''
9
+ #### output format
10
+ [('Whose song does I like?', 'HuiLin Chen')]
11
+ '''
12
+
13
+
14
+ #t2t.Handler(["{} [SEP] {}".format(eng_context, "SNPL")], src_lang='en').question()
15
+ def gen_ask_by_span_en(t2t ,sent, span):
16
+ assert type(sent) == type("")
17
+ #assert type(span) == type("")
18
+ if type(span) == type(""):
19
+ span = [span]
20
+ if not span:
21
+ return []
22
+ req = []
23
+ for ele in tqdm(span):
24
+ output = t2t.Handler(["{} [SEP] {}".format(sent, ele)], src_lang='en').question()
25
+ assert type(output) == type([])
26
+ assert bool(output)
27
+ output = output[0][0]
28
+ assert type(output) == type("")
29
+ req.append(output)
30
+ return req