public virtual void TestPreservesIndex()
        {
            int a = tt.Add("spunky");
            int b = tt.GetIndex("spunky");

            NUnit.Framework.Assert.AreEqual(a, b);
        }
Example #2
0
 protected internal AmbiguityClass(string word, bool single, Dictionary dict, TTags ttags)
 {
     // import java.util.HashSet;
     // private final HashSet<String> s;
     this.single = single;
     if (single)
     {
         this.word = word;
         sortedIds = Java.Util.Collections.EmptyList();
     }
     else
     {
         this.word = null;
         string[] tags = dict.GetTags(word);
         sortedIds = new List <int>(tags.Length);
         foreach (string tag in tags)
         {
             Add(ttags.GetIndex(tag));
         }
     }
     // s = Generics.newHashSet();
     // for (Integer sortedId : sortedIds) {
     //   s.add(ttags.getTag(sortedId));
     // }
     key = this.ToString();
 }
        public virtual void TestSerialization()
        {
            for (int i = 0; i < 100; i++)
            {
                tt.Add("fake" + int.ToString(i));
            }
            tt.MarkClosed("fake44");
            tt.Add("boat");
            tt.Save("testoutputfile", Generics.NewHashMap <string, ICollection <string> >());
            TTags t2 = new TTags();

            t2.Read("testoutputfile");
            NUnit.Framework.Assert.AreEqual(tt.GetSize(), t2.GetSize());
            NUnit.Framework.Assert.AreEqual(tt.GetIndex("boat"), t2.GetIndex("boat"));
            NUnit.Framework.Assert.AreEqual(t2.GetTag(tt.GetIndex("boat")), "boat");
            NUnit.Framework.Assert.IsFalse(t2.IsClosed("fake43"));
            NUnit.Framework.Assert.IsTrue(t2.IsClosed("fake44"));
            /* java=lame */
            (new File("testoutputfile")).Delete();
        }