コード例 #1
0
 private void LoadMWMap(string filename)
 {
     mwCounter = new TwoDimensionalCounter <string, string>();
     try
     {
         BufferedReader br     = new BufferedReader(new InputStreamReader(new FileInputStream(new File(filename)), "UTF-8"));
         int            nLines = 0;
         for (string line; (line = br.ReadLine()) != null; nLines++)
         {
             string[] toks = line.Split("\t");
             System.Diagnostics.Debug.Assert(toks.Length == 3);
             mwCounter.SetCount(toks[0].Trim(), toks[1].Trim(), double.Parse(toks[2].Trim()));
         }
         br.Close();
         System.Console.Error.Printf("%s: Loaded %d lines from %s into MWE counter%n", this.GetType().FullName, nLines, filename);
     }
     catch (UnsupportedEncodingException e)
     {
         Sharpen.Runtime.PrintStackTrace(e);
     }
     catch (FileNotFoundException e)
     {
         Sharpen.Runtime.PrintStackTrace(e);
     }
     catch (IOException e)
     {
         Sharpen.Runtime.PrintStackTrace(e);
     }
 }
コード例 #2
0
 public virtual void TestSetCount()
 {
     NUnit.Framework.Assert.AreEqual(c.TotalCount(), 21.0);
     c.SetCount("p", "q", 1.0);
     NUnit.Framework.Assert.AreEqual(c.TotalCount(), 22.0);
     NUnit.Framework.Assert.AreEqual(c.TotalCount("p"), 1.0);
     NUnit.Framework.Assert.AreEqual(c.GetCount("p", "q"), 1.0);
     c.Remove("p", "q");
 }
コード例 #3
0
 protected virtual void SetUp()
 {
     c = new TwoDimensionalCounter <string, string>();
     c.SetCount("a", "a", 1.0);
     c.SetCount("a", "b", 2.0);
     c.SetCount("a", "c", 3.0);
     c.SetCount("b", "a", 4.0);
     c.SetCount("b", "b", 5.0);
     c.SetCount("c", "a", 6.0);
 }