plot_summary_lenghts.R
1.71 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require(ggplot2)
require(grid)
require(gridExtra)
require(lattice)
DATA_DIR="../../../../data/"
########################## functions
gpl = function(d) {
ggplot(d, aes(x=as.factor(d$SumRatio), y=SumRealRatio)) +
geom_boxplot(outlier.shape=4, outlier.colour = "blue") +
ylim(0, 40) +
ylab("Obtained summary ratio (word count)") +
xlab("Requested summary ratio (word count)") +
theme(text = element_text(size=15))
}
ploto = function(d) {
p = gpl(d)
}
histo = function(d) {
p = ggplot(d, aes(abs(d$SumRealRatio*100/d$SumRatio))) +
geom_histogram(binwidth = 1) +
xlim(80, 120) +
ylab("Number of summaries") +
xlab("Obtained summary ratio as percent of requested ratio (20%)") +
theme(text = element_text(size=15))
}
######################### automatic summaries
data = read.csv(paste(DATA_DIR, "summary-lengths.tsv", sep=""), sep = "\t")
names = list("Swietl", "nicolas", "nicolas-zero", "BASELINE")
titles = list("Świetlicka", "Nicolas", "Nicolas-zero", "Baseline")
plots = list()
hists = list()
i = 1
for (n in names) {
print(n)
title = titles[[i]]
i = i + 1
d = data[data$SumAuthor==n,]
print(mean(d$SumRealRatio))
p = ploto(d)
p = p + ggtitle(title)
plots = c(plots, list(p))
hi = histo(d)
hi = hi + ggtitle(title)
hists = c(hists, list(hi))
}
pdf(file=paste(DATA_DIR, "summary-length-plots.pdf", sep=""), encoding="ISOLatin2", width=11.69, height=8.27)
grid.arrange(plots[[1]], plots[[2]], plots[[3]], plots[[4]], ncol=2, nrow=2)
dev.off()
pdf(file=paste(DATA_DIR, "summary-length-hists.pdf", sep=""), encoding="ISOLatin2", width=11.69, height=8.27)
grid.arrange(hists[[1]], hists[[2]], hists[[3]], hists[[4]], ncol=2, nrow=2)
dev.off()