Hello Brother, Sister, Buddy, Programmer, Master. :) :) :)
Based on running time for searching, this code take its too long.
Please give recommendation for making it efficient.
How to change or improve my code like this :
static List<string> getDBList(string DBname)
{
List<string> listWords = new List<string>();
string[] files;
try
{
files = Directory.GetFiles(@"dbase/", DBname);
foreach (string file in files)
foreach (string line in File.ReadAllLines(file))
listWords.Add(line.Trim().ToUpperInvariant());
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return new List<string> { };
}
return listWords;
}
Then...
string allInput = rtbInput.Text;
List<string> splitString = new List<string>.Split(new char[] { ' ', '\t', etc...});
List<int> AllIndexes = new List<int>();
HashSet<string> nounList = new HashSet<string>(getDBList("nounList.txt"));
int startIndexes = 0;
foreach (string s in splitString)
{
if (s.Trim() != "")
{
string word = s.Trim();
if(!(nounList.Contains(word.ToUpperInvariant())))
{
tbTest.Text += word + " ";
AllIndexes = WordsIndex(word, startIndexes);
foreach (int item in AllIndexes)
{
tbSeeIndex.Text += Convert.ToString(" " + item + " ");
rtbInput.Select(item, word.Length);
startIndexes = item + word.Length;
rtbInput.SelectionColor = Color.Red;
}
tbL.Text += Convert.ToString(" " + startIndexes + " ");
}
}
}
in nounList (90963 word), content like this example :
book
chari
pencil
table
etc...
Please help me.....
Thanks a lot. :) :) :) Cheers