public void Construct() { var stream = new CompressedDictionaryStream("Resources.Dictionary.RawEnglish.dat", new EmbeddedStreamSource <WordsDictionary>()); var table = stream.ReadDataFromStream(double.Parse).ToDictionary(item => item.Word, item => item.Value); Assert.AreEqual(44323, table.Count); }
public void Construct() { var path = ConfigurationManager.AppSettings["resources"]; var file = Path.Combine(TestContext.CurrentContext.TestDirectory, path, @"Embedded\Dictionary\NRC.txt"); var stream = new DictionaryStream(file, new FileStreamSource()); var table = stream.ReadDataFromStream(double.Parse).ToArray(); Assert.AreEqual(141820, table.Length); file = Path.Combine(TestContext.CurrentContext.TestDirectory, "NRC.dat"); if (File.Exists(file)) { File.Delete(file); } var outStream = new CompressedDictionaryStream(file, new FileStreamSource()); DictionaryStreamExtension.WriteStream(file, table.Select(item => new KeyValuePair <string, double>(item.Word, item.Value)), Encoding.ASCII); table = outStream.ReadDataFromStream(double.Parse).ToArray(); Assert.AreEqual(141820, table.Length); }