File size: 501 Bytes
32de449
 
979b6d8
32de449
 
 
 
 
979b6d8
 
32de449
 
979b6d8
 
 
32de449
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from datasets import load_dataset
import matplotlib.pyplot as plt
from os.path import dirname, join

dataset = load_dataset("undertheseanlp/UTS_Text_v1")
sentences = dataset["train"]["text"]

# compute histogram of sentence lengths with bin size = 10
pwd = dirname(__file__)
tmp = join(pwd, "tmp")
lengths = [len(s) for s in sentences]
plt.hist(lengths, bins=range(0, max(lengths), 10))
# add title of plot
plt.title("Histogram of sentence lengths")
plt.savefig(join(tmp, "histogram.png"))
plt.show()