rain1024 commited on
Commit
093e18b
·
1 Parent(s): b7cf6a5
Files changed (2) hide show
  1. data/UTS_Text_v1.txt +0 -0
  2. generate_dataset.py +7 -12
data/UTS_Text_v1.txt ADDED
The diff for this file is too large to render. See raw diff
 
generate_dataset.py CHANGED
@@ -8,7 +8,7 @@ with open(text_file) as f:
8
  lines = f.read().splitlines()
9
  NUM_LONG_TOKENS = 50
10
  NUM_SHORT_TOKENS = 20
11
- NUM_MAX_TOKENS = 150
12
 
13
 
14
  def longline_conditions(line):
@@ -20,11 +20,7 @@ def longline_conditions(line):
20
 
21
 
22
  long_lines = [line for line in lines if longline_conditions(line)]
23
- # get random 1000 lines
24
- random_long_lines = random.sample(long_lines, 5000)
25
- for line in random_long_lines[:20]:
26
- print(line)
27
-
28
 
29
  def shortline_conditions(line):
30
  if len(line) < NUM_SHORT_TOKENS:
@@ -37,18 +33,17 @@ def shortline_conditions(line):
37
 
38
 
39
  short_lines = [line for line in lines if shortline_conditions(line)]
40
- random_short_lines = random.sample(short_lines, 5000)
41
- for line in random_short_lines[:20]:
42
- print(line)
43
 
44
- print("Long lines", len(random_long_lines))
45
- print("Short lines", len(random_short_lines))
46
 
47
  pwd = dirname(__file__)
48
  tmp = join(pwd, "data")
49
  corpus_file = join(tmp, "UTS_Text_v1.txt")
50
 
51
  with open(corpus_file, "w") as f:
52
- lines = random_long_lines + random_short_lines
 
53
  content = "\n".join(lines)
54
  f.write(content)
 
8
  lines = f.read().splitlines()
9
  NUM_LONG_TOKENS = 50
10
  NUM_SHORT_TOKENS = 20
11
+ NUM_MAX_TOKENS = 200
12
 
13
 
14
  def longline_conditions(line):
 
20
 
21
 
22
  long_lines = [line for line in lines if longline_conditions(line)]
23
+ print("Short lines", len(long_lines))
 
 
 
 
24
 
25
  def shortline_conditions(line):
26
  if len(line) < NUM_SHORT_TOKENS:
 
33
 
34
 
35
  short_lines = [line for line in lines if shortline_conditions(line)]
36
+ print("Short lines", len(short_lines))
 
 
37
 
38
+ print("Long lines", len(long_lines))
39
+ print("Short lines", len(short_lines))
40
 
41
  pwd = dirname(__file__)
42
  tmp = join(pwd, "data")
43
  corpus_file = join(tmp, "UTS_Text_v1.txt")
44
 
45
  with open(corpus_file, "w") as f:
46
+ lines = long_lines + short_lines
47
+ lines = lines[:1000]
48
  content = "\n".join(lines)
49
  f.write(content)