我想从数据库中检索一些单词,然后我将判断段落是正段还是负段
。数据库文件格式是这样的。其中一些关键词有正负分
Word Pos_Score Neg_Score
Able .324 .834
Country .987 .213
Love .378 .734
agree .546 .123
industry .289 .714
guests .874 .471
段落将是这样的。
I agree with you. It seems an intelligent tourist industry allows its guests to either immerse fully, in part, or not, depending upon the guest. That is why the ugly American charges have always confused me.
现在,如果在数据库文件中找到单词,我会将段落的每个单词与数据库文件进行比较,然后我将检索单词的 Pos_Scoe 和 Neg_Score 分数,当整个段落最后比较时,这些分数将存储在变量中 Pos_Score 将单独添加,Neg_Score 将单独添加。这将是结果。
我尝试的代码是这个
private void button1_Click(object sender, EventArgs e)
{
string MyConString = "server=localhost;" +
"database=sentiwornet;" + "password=zia;" +
"User Id=root;";
MySqlConnection connection = new MySqlConnection(MyConString);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
StreamReader reader = new StreamReader("D:\\input.txt");
string line;
while ((line = reader.ReadLine()) != null)
{
string[] parts = line.Split(' ');
foreach (string part in parts)
{
command.CommandText = "SELECT Pos_Score FROM score WHERE Word = 'part'";
command.CommandText = "SELECT Neg_Score FROM score WHERE Word = 'part'";
//var
connection.Open();
Reader = command.ExecuteReader();
}
}
}