Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace PartA
- {
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading;
- class Program
- {
- static void Main(string[] args)
- {
- // START TIME
- var watch = System.Diagnostics.Stopwatch.StartNew();
- watch.Start();
- System.Diagnostics.Debug.WriteLine(watch.Elapsed);
- // READ FILE
- var reader = new ReadFile("..\\..\\..\\corpus");
- reader.Read();
- var docs = reader.GetDocs();
- // PARSE
- /*
- var parsed = new Dictionary<string, Dictionary<Parser.ClassifiedValue, List<string>>>();
- var index = 1;
- int running = docs.Count;
- AutoResetEvent done = new AutoResetEvent(false);
- foreach (var listOfdocs in docs)
- {
- ThreadPool.QueueUserWorkItem(state =>
- {
- foreach (var doc in listOfdocs)
- {
- //Thread.CurrentThread.IsBackground = true;
- var parser = new Parser(doc, "..\\..\\..\\stop_words.txt");
- parser.Parse();
- parsed[doc] = parser.Result;
- }
- if (0 == Interlocked.Decrement(ref running))
- {
- done.Set();
- }
- Interlocked.Increment(ref index);
- System.Diagnostics.Debug.WriteLine("doc " + index + " done.");
- });
- }
- done.WaitOne();
- // INDEX
- var indexer = new Indexer();
- foreach (var listOfdocs in docs)
- {
- System.Diagnostics.Debug.WriteLine("ssssnnn : " + docs.IndexOf(listOfdocs));
- foreach (var doc in listOfdocs)
- {
- // ThreadPool.QueueUserWorkItem(state =>
- // {
- // Thread.CurrentThread.IsBackground = true;
- indexer.CreateDocsIndex(doc, parsed[doc]);
- // });
- }
- // END TIME
- watch.Stop();
- System.Diagnostics.Debug.WriteLine(watch.Elapsed);
- }
- */
- watch.Stop();
- System.Diagnostics.Debug.WriteLine(watch.Elapsed);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement