【发布时间】:2013-03-07 04:35:11
【问题描述】:
我想从数据库中检索一些单词,然后我将决定这是正段还是负段
数据库文件格式是这样的。其中一些关键词有正负分
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 分数,当整个段落将比较时,这些分数将存储在变量中end 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();
}
}
}
【问题讨论】:
-
您的数据库中大约有多少个单词?
-
@rmayer06: 32,000 个单词将在数据库中
标签: c# mysql c#-4.0 mysql-workbench