示例#1
0
 public static void MakeLex(string infile, string outfile)
 {
     try
     {
         Hashtable hash = new Hashtable();
         //int count = 0;
         StreamReader reader = HostSystem.GetStreamReader(infile);
         string       line;
         do
         {
             line = reader.ReadLine();
             if (line == null)
             {
                 break;
             }
             int index = line.IndexOf(" ");
             //Console.WriteLine("line: " + line + " index: " + index);
             string word = line.Substring(0, index).Trim();
             string tags = line.Substring(index).Trim();
             //Console.WriteLine("word: " + word + ", tags: " + tags);
             //count++;
             if (hash[word] == null)
             {
                 hash.Add(word, tags);
             }
             // ReSharper disable ConditionIsAlwaysTrueOrFalse
         } while (line != null);
         // ReSharper restore ConditionIsAlwaysTrueOrFalse
         reader.Close();
         Stream     file      = HostSystem.Open(outfile, FileMode.Create);
         IFormatter formatter = (IFormatter) new BinaryFormatter();
         // Serialize the object hashto stream
         formatter.Serialize(file, hash);
         file.Close();
     }
     catch (Exception e2)
     {
         DLRConsole.DebugWriteLine("Error: " + e2);
     }
 }