109,894
社区成员




想使用结巴分词分析器的一个实例,使用了下面的语句:
Analyzer analyzer = new JiebaAnalyzer();
错误 CS0246 未能找到类型或命名空间名“JiebaAnalyzer”(是否缺少 using 指令或程序集引用?)
在网上找到了一个重写JiebaAnalyzer类的帖子:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using JiebaNet.Segmenter;
using Lucene.Net.Analysis;
namespace WindowsFormsApp1
{
public class JiebaAnalyzer : Analyzer //这一句的JiebaAnalyzer下方显示红色折线
{
protected static readonly ISet<string> DefaultStopWords = StopAnalyzer.ENGLISH_STOP_WORDS_SET;
private static ISet<string> StopWords;
static JiebaAnalyzer()
{
var stopWordsFile = Path.GetFullPath(JiebaNet.Analyser.ConfigManager.StopWordsFile);
if (File.Exists(stopWordsFile))
{
var lines = File.ReadAllLines(stopWordsFile);
StopWords = new HashSet<string>();
foreach (var line in lines)
{
StopWords.Add(line.Trim());
}
}
else
{
StopWords = DefaultStopWords;
}
}
}
}
我使用NeGut安装了jieba.net,编译程序后,在应用程序目录出现了JiebaNet.Analyser.dll,在网上没有看到有Lucene.Net.Analysis.dll,估计是Lucene.Net.dll中的一个类。
winform程序引用了net.core组件会怎样?我估计jieba.net是net.core组件。