我正在阅读文档,并拆分单词以获取字典中的每个单词,但是我怎么能排除一些单词(例如“the/a/an”)。
这是我的功能:
private void Splitter(string[] file)
{
try
{
tempDict = file
.SelectMany(i => File.ReadAllLines(i)
.SelectMany(line => line.Split(new[] { ' ', ',', '.', '?', '!', }, StringSplitOptions.RemoveEmptyEntries))
.AsParallel()
.Distinct())
.GroupBy(word => word)
.ToDictionary(g => g.Key, g => g.Count());
}
catch (Exception ex)
{
Ex(ex);
}
}
另外,在这种情况下,添加.ToLower()
调用以使文件中的所有单词都变为小写的正确位置在哪里?temp = file
在( ..)之前我正在考虑这样的事情:
file.ToList().ConvertAll(d => d.ToLower());