小编you*_*ist的帖子

在Twitter情绪分析项目中寻找C#中的开源朴素贝叶斯分类器

我在这里找到了一个类似的项目:用Python进行Twitter的情感分析.但是,我正在研究C#,需要使用一个开源的朴素贝叶斯分类器.除非有人能够阐明我如何利用python贝叶斯分类器来实现相同的目标.有任何想法吗?

c# twitter classification bayesian

11
推荐指数
1
解决办法
1万
查看次数

C# 进程无法访问文件“”,因为它正在被另一个进程使用

代码片段只是应该将字符串写入名为“all_results.txt”的文本文件中。我在 File.WriteAllText 中实现时出错。在网上搜索解决方案后,我尝试使用 FileStream 和 StreamWriter 作为替代品。问题仍然存在。

它给了我:

IOException 未处理:进程无法访问文件“C:\Users\MadDebater\Desktop\ConsoleTest1\ConsoleTest\bin\Debug\all_results.txt”,因为它正在被另一个进程使用。

奇怪的是,错误是任意发生的。它可能是在第 3 次循环期间或第 45 次循环期间发生错误。我提供了该类的完整代码,以防问题比看起来更严重。我确信这与我的病毒扫描程序或类似的东西无关。

try
                {
                    using (FileStream stream = new FileStream(@"all_results.txt", FileMode.Create)) // Exception here
                {
                    using (StreamWriter writer = new StreamWriter(stream))
                    {
                        writer.WriteLine(result);
                        writer.Dispose();
                        writer.Close();
                    }

                    stream.Dispose();
                    stream.Close();
                }

                }
                catch (IOException ex)
                {
                    Console.WriteLine(ex);
                }
Run Code Online (Sandbox Code Playgroud)

即使我尝试这样做,它仍然失败。

try
                {
                    File.WriteAllText(@"all_results.txt", result); // Exception here
                }
                catch (IOException ex)
                {
                    Console.WriteLine(ex.Message);
                }
Run Code Online (Sandbox Code Playgroud)

以下是该类的完整代码。它的目的是接收 Twitter 推文列表,并使用贝叶斯分类将它们一一分类。

    using System;
    using System.IO;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using BayesClassifier;
    using …
Run Code Online (Sandbox Code Playgroud)

c# asp.net visual-studio-2010 ioexception

6
推荐指数
1
解决办法
4万
查看次数