在文本文件中搜索多个关键字 [英] Searching muliple keywords in a text file
问题描述
大家好,
我需要在一个巨大的多个文本文件中搜索大约90000个关键字。我已经实现了这个功能,但是由于需要扫描大量的关键字,这个过程需要很长时间。
目前我已经实现了一个for循环并扫描所有文本文件中的每个关键字但是这个过程很好,关键字数量很少。现在,当我的关键字增长时,这需要很长的时间。
任何人都可以提供一些解决方案来最小化此要求所需的时间
Hi all,
I have some 90000 keywords that I need to search on a huge multiple text files. I have implemented this functionality, but due to the huge number of keyword to be scanned the process takes a long time.
Currently I have implemented a for loop and scan each and every keyword on all the text files but this process was fine with small number of keywords. Now when my keywords grew this takes a huge time.
Can anyone provide some resolution to minimize the time required for this requirement
推荐答案
以最快的方式搜索文本 [ ^ ]
嗨试试这个,
hi try this,
string StrValue_FD = "Hello hi Hi hello length and are you length hi.";
var split = StrValue_FD.ToUpper().Split(' ');
int length = split.Length;
List<string> list = new List<string>();
while (length > 0)
{
list.Add(split[length - 1]);
length--;
}
var result = list.GroupBy(str => str).ToDictionary(str => str.Key, str => str.Count());</string></string>
你可以尝试这个例子。结果你可以得到每个单词的出现次数。
you can try this example. In result you can get the each word number of times occured.
这篇关于在文本文件中搜索多个关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!