rain1024 commited on
Commit
979b6d8
1 Parent(s): 6d4d9c7
Files changed (2) hide show
  1. eval.py +6 -8
  2. tmp/.gitignore +2 -0
eval.py CHANGED
@@ -1,18 +1,16 @@
1
  from datasets import load_dataset
2
  import matplotlib.pyplot as plt
 
3
 
4
  dataset = load_dataset("undertheseanlp/UTS_Text_v1")
5
  sentences = dataset["train"]["text"]
6
 
7
  # compute histogram of sentence lengths with bin size = 10
 
 
8
  lengths = [len(s) for s in sentences]
9
  plt.hist(lengths, bins=range(0, max(lengths), 10))
 
 
 
10
  plt.show()
11
-
12
- # n_sample = 0
13
- # for s in sentences:
14
- # if len(s) > 150:
15
- # print(s)
16
- # n_sample += 1
17
- # if n_sample == 10:
18
- # break
 
1
  from datasets import load_dataset
2
  import matplotlib.pyplot as plt
3
+ from os.path import dirname, join
4
 
5
  dataset = load_dataset("undertheseanlp/UTS_Text_v1")
6
  sentences = dataset["train"]["text"]
7
 
8
  # compute histogram of sentence lengths with bin size = 10
9
+ pwd = dirname(__file__)
10
+ tmp = join(pwd, "tmp")
11
  lengths = [len(s) for s in sentences]
12
  plt.hist(lengths, bins=range(0, max(lengths), 10))
13
+ # add title of plot
14
+ plt.title("Histogram of sentence lengths")
15
+ plt.savefig(join(tmp, "histogram.png"))
16
  plt.show()
 
 
 
 
 
 
 
 
tmp/.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ *
2
+ !.gitignore