-
Notifications
You must be signed in to change notification settings - Fork 0
/
Train.aspx.cs
199 lines (181 loc) · 7.37 KB
/
Train.aspx.cs
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
public partial class Admin_Train : System.Web.UI.Page
{
save s = new save();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (DropDownList1.Text == "Godaddy")
{
string getvalue = Get_HTML("http://www.mouthshut.com/websites/Godaddy-com-reviews-925641288");
// Response.Write(getvalue);
using (StreamWriter outfile = new StreamWriter(Server.MapPath("~/Textfiles/TextFile.txt")))
{
outfile.Write(getvalue);
}
}
if (DropDownList1.Text == "Bigrock")
{
string getvalue = Get_HTML("http://www.mouthshut.com/websites/Bigrock-in-reviews-925641276");
// Response.Write(getvalue);
using (StreamWriter outfile = new StreamWriter(Server.MapPath("~/Textfiles/TextFile7.txt")))
{
outfile.Write(getvalue);
}
}
if (DropDownList1.Text == "Bluehost")
{
string getvalue = Get_HTML("http://www.mouthshut.com/websites/Bluehost-in-reviews-925872109");
// Response.Write(getvalue);
using (StreamWriter outfile = new StreamWriter(Server.MapPath("~/Textfiles/TextFile8.txt")))
{
outfile.Write(getvalue);
}
}
}
public static bool SearchWord(string word, string path)
{
StreamReader re = File.OpenText(path);
string input = null;
while ((input = re.ReadLine()) != null)
{
if (input.IndexOf(word, 0) > 0)
{
return true;
}
}
return false;
}
public static string Get_HTML(string Url)
{
System.Net.WebResponse Result = null;
string Page_Source_Code;
try
{
System.Net.WebRequest req = System.Net.WebRequest.Create(Url);
Result = req.GetResponse();
System.IO.Stream RStream = Result.GetResponseStream();
System.IO.StreamReader sr = new System.IO.StreamReader(RStream);
new System.IO.StreamReader(RStream);
Page_Source_Code = sr.ReadToEnd();
sr.Dispose();
}
catch
{
// error while reading the url: the url dosen’t exist, connection problem...
Page_Source_Code = "";
}
finally
{
if (Result != null) Result.Close();
}
return Page_Source_Code;
}
protected void ddlrest_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
if (DropDownList1.Text == "Godaddy")
{
StreamReader sr = new StreamReader(Server.MapPath("~/Textfiles/TextFile.txt"));
String line = sr.ReadToEnd();
sr.Close();
// textBox2.Text = line;
string positiveKeyword = "good,excellent,delight,verygood,awesome";
string[] words = positiveKeyword.Split(',');
string negativeKeyword = "bad,worst,awful,extremely bad";
string[] negativewords = negativeKeyword.Split(',');
int i = 0, j = 0;
foreach (string str in words)
{
foreach (string nstr in negativewords)
{
if (SearchWord(str, Server.MapPath("~/Textfiles/TextFile.txt")) == true)
{
i++;
}
else if (SearchWord(nstr, Server.MapPath("~/Textfiles/TextFile.txt")) == true)
{
j++;
}
}
}
int rate = i - j;
int totalrate = i + j;
decimal entropy = rate / totalrate;
decimal log =Convert.ToDecimal( Math.Log(totalrate, 2));
s.insert("update [Rating] set PositiveRating='" + i + "',NegativeRating='" + j + "',TotalRating='" + totalrate + "',Entropy='" + entropy + "',Ratinglog='"+log+"' where [CompanyName]='" + DropDownList1.Text + "'");
}
if (DropDownList1.Text == "Bigrock")
{
StreamReader sr = new StreamReader(Server.MapPath("~/Textfiles/TextFile7.txt"));
String line = sr.ReadToEnd();
sr.Close();
// textBox2.Text = line;
string positiveKeyword = "good,excellent,delight,verygood,awesome";
string[] words = positiveKeyword.Split(',');
string negativeKeyword = "bad,worst,awful,extremely bad";
string[] negativewords = negativeKeyword.Split(',');
int i = 0, j = 0;
foreach (string str in words)
{
foreach (string nstr in negativewords)
{
if (SearchWord(str, Server.MapPath("~/Textfiles/TextFile7.txt")) == true)
{
i++;
}
else if (SearchWord(nstr, Server.MapPath("~/Textfiles/TextFile7.txt")) == true)
{
j++;
}
}
}
int rate = i - j;
int totalrate = i + j;
decimal entropy = Convert.ToDecimal(rate / totalrate);
decimal log = Convert.ToDecimal(Math.Log(totalrate, 2));
s.insert("update [Rating] set PositiveRating='" + i + "',NegativeRating='" + j + "',TotalRating='" + totalrate + "',Entropy='" + entropy + "',Ratinglog='" + log + "' where [CompanyName]='" + DropDownList1.Text + "'");
}
if (DropDownList1.Text == "Bluehost")
{
StreamReader sr = new StreamReader(Server.MapPath("~/Textfiles/TextFile8.txt"));
String line = sr.ReadToEnd();
sr.Close();
// textBox2.Text = line;
string positiveKeyword = "good,excellent,delight,verygood,awesome";
string[] words = positiveKeyword.Split(',');
string negativeKeyword = "bad,worst,awful,extremely bad";
string[] negativewords = negativeKeyword.Split(',');
int i = 0, j = 0;
foreach (string str in words)
{
foreach (string nstr in negativewords)
{
if (SearchWord(str, Server.MapPath("~/Textfiles/TextFile8.txt")) == true)
{
i++;
}
else if (SearchWord(nstr, Server.MapPath("~/Textfiles/TextFile8.txt")) == true)
{
j++;
}
}
}
int rate = i - j;
int totalrate = i + j;
decimal entropy = rate / totalrate;
decimal log = Convert.ToDecimal(Math.Log(totalrate, 2));
s.insert("update [Rating] set PositiveRating='" + i + "',NegativeRating='" + j + "',TotalRating='" + totalrate + "',Entropy='" + entropy + "',Ratinglog='" + log + "' where [CompanyName]='" + DropDownList1.Text + "'");
}
}
}