public virtual void TestCopy() { CategoryWordTag tag = new CategoryWordTag("A", "B", "C"); NUnit.Framework.Assert.AreEqual("A", tag.Category()); NUnit.Framework.Assert.AreEqual("B", tag.Word()); NUnit.Framework.Assert.AreEqual("C", tag.Tag()); CategoryWordTag tag2 = new CategoryWordTag(tag); NUnit.Framework.Assert.AreEqual("A", tag2.Category()); NUnit.Framework.Assert.AreEqual("B", tag2.Word()); NUnit.Framework.Assert.AreEqual("C", tag2.Tag()); }
private Tree TransformTreeHelper(Tree t) { if (t != null) { string cat = t.Label().Value(); if (t.IsLeaf()) { ILabel label = new Word(cat); //new CategoryWordTag(cat,cat,""); t.SetLabel(label); } else { Tree[] kids = t.Children(); foreach (Tree child in kids) { TransformTreeHelper(child); } // recursive call Tree headChild = hf.DetermineHead(t); string tag; string word; if (headChild == null) { log.Error("null head for tree\n" + t.ToString()); word = null; tag = null; } else { if (headChild.IsLeaf()) { tag = cat; word = headChild.Label().Value(); } else { CategoryWordTag headLabel = (CategoryWordTag)headChild.Label(); word = headLabel.Word(); tag = headLabel.Tag(); } } ILabel label = new CategoryWordTag(cat, word, tag); t.SetLabel(label); } } return(t); }
public virtual void TestCopy() { CategoryWordTag tag = new CategoryWordTag("A", "B", "C"); NUnit.Framework.Assert.AreEqual("A", tag.Category()); NUnit.Framework.Assert.AreEqual("B", tag.Word()); NUnit.Framework.Assert.AreEqual("C", tag.Tag()); CategoryWordTagFactory lf = new CategoryWordTagFactory(); ILabel label = lf.NewLabel(tag); NUnit.Framework.Assert.IsTrue(label is CategoryWordTag); CategoryWordTag tag2 = (CategoryWordTag)label; NUnit.Framework.Assert.AreEqual("A", tag2.Category()); NUnit.Framework.Assert.AreEqual("B", tag2.Word()); NUnit.Framework.Assert.AreEqual("C", tag2.Tag()); }