-
Notifications
You must be signed in to change notification settings - Fork 0
/
eval .r
167 lines (125 loc) · 3.98 KB
/
eval .r
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#evaluation
logFile<-"C:\\Users\\Atul\\Desktop\\log.txt"
print("Original C4.5 Algorithim")
corpus1<- VCorpus(DirSource("C:\\Users\\Atul\\Desktop\\summ\\summary_t"), readerControl = list(reader = readPlain))
corpus2<- VCorpus(DirSource("C:/Users/Atul/Desktop/summ/t summary"), readerControl = list(reader = readPlain))
recall<-0
precision<-0
for(i in 1: length(corpus1))
{
standard<-corpus1[[i]]
system<-corpus2[[i]]
standard<-as.String(standard)
system<-as.String(system)
sent_tokenizer<-Maxent_Sent_Token_Annotator()
st<-annotate(standard,sent_tokenizer)
sys<-annotate(system,sent_tokenizer)
spans_of_sentences <- as.Span(sys[sys$type == "sentence"])
no_standard<-length(st)
no_system<-length(sys)
count<-0
for(j in 1:length(spans_of_sentences))
{
if(grepl(system[spans_of_sentences[j]],standard,fixed=TRUE)==TRUE)
count<-count+1
##print(count)
}
recall<-recall+count/no_standard
##print(recall)
precision<-precision+count/no_system
##print(precision)
}
recall<-recall/length(corpus1)
precision<-precision/length(corpus1)
f_score<-2*precision*recall/(precision+recall)
cat("\nInfo_gain_tree\n",file=logFile,append=TRUE)
cat("\n Recall\n",file=logFile,append=TRUE)
cat( recall,file=logFile,append=TRUE)
cat("\n Precision\n",file=logFile,append=TRUE)
cat( precision,file=logFile,append=TRUE)
cat("\n Fscore\n",file=logFile,append=TRUE)
cat( f_score,file=logFile,append=TRUE)
rm(corpus1)
rm(corpus2)
print("Algorithim 1")
corpus1<- VCorpus(DirSource("C:\\Users\\Atul\\Desktop\\summ\\summary_p"), readerControl = list(reader = readPlain))
corpus2<- VCorpus(DirSource("C:/Users/Atul/Desktop/summ/t summary"), readerControl = list(reader = readPlain))
recall<-0
precision<-0
for(i in 1: length(corpus1))
{
standard<-corpus1[[i]]
system<-corpus2[[i]]
standard<-as.String(standard)
system<-as.String(system)
sent_tokenizer<-Maxent_Sent_Token_Annotator()
st<-annotate(standard,sent_tokenizer)
sys<-annotate(system,sent_tokenizer)
spans_of_sentences <- as.Span(sys[sys$type == "sentence"])
no_standard<-length(st)
no_system<-length(sys)
count<-0
for(j in 1:length(spans_of_sentences))
{
if(grepl(system[spans_of_sentences[j]],standard,fixed=TRUE)==TRUE)
count<-count+1
##print(count)
}
recall<-recall+count/no_standard
##print(recall)
precision<-precision+count/no_system
##print(precision)
}
recall<-recall/length(corpus1)
precision<-precision/length(corpus1)
f_score<-2*precision*recall/(precision+recall)
cat("\nAlgo1\n",file=logFile,append=TRUE)
cat("\n Recall\n",file=logFile,append=TRUE)
cat( recall,file=logFile,append=TRUE)
cat("\n Precision\n",file=logFile,append=TRUE)
cat( precision,file=logFile,append=TRUE)
cat("\n Fscore\n",file=logFile,append=TRUE)
cat( f_score,file=logFile,append=TRUE)
rm(corpus1)
rm(corpus2)
print("Algorithim 2")
corpus1<- VCorpus(DirSource("C:\\Users\\Atul\\Desktop\\summ\\summary_q"), readerControl = list(reader = readPlain))
corpus2<- VCorpus(DirSource("C:/Users/Atul/Desktop/summ/t summary"), readerControl = list(reader = readPlain))
recall<-0
precision<-0
for(i in 1: length(corpus1))
{
standard<-corpus1[[i]]
system<-corpus2[[i]]
standard<-as.String(standard)
system<-as.String(system)
sent_tokenizer<-Maxent_Sent_Token_Annotator()
st<-annotate(standard,sent_tokenizer)
sys<-annotate(system,sent_tokenizer)
spans_of_sentences <- as.Span(sys[sys$type == "sentence"])
no_standard<-length(st)
no_system<-length(sys)
count<-0
for(j in 1:length(spans_of_sentences))
{
if(grepl(system[spans_of_sentences[j]],standard,fixed=TRUE)==TRUE)
count<-count+1
##print(count)
}
recall<-recall+count/no_standard
##print(recall)
precision<-precision+count/no_system
##print(precision)
}
recall<-recall/length(corpus1)
precision<-precision/length(corpus1)
f_score<-2*precision*recall/(precision+recall)
cat("\nAlgo2\n",file=logFile,append=TRUE)
cat("\n Recall\n",file=logFile,append=TRUE)
cat( recall,file=logFile,append=TRUE)
cat("\n Precision\n",file=logFile,append=TRUE)
cat( precision,file=logFile,append=TRUE)
cat("\n Fscore\n",file=logFile,append=TRUE)
cat( f_score,file=logFile,append=TRUE)
rm(corpus1)
rm(corpus2)