예제 #1
0
        public static void AddToDataTreeBoyerMoore(IDataTree dataTree, string content)
        {
            if (dataTree == null || content == null)
            {
                throw new ArgumentNullException();
            }
            if (dataTree.GetBaseTree() == null)
            {
                throw new InvalidOperationException("Data Tree's base tree cannot be null");
            }

            content = StringFunctions.Normalize(content);
            if (dataTree is StemmedDocumentMap)
            {
                content = StringFunctions.StemmedWord(content);
            }
            foreach (Node n in dataTree.GetBaseTree())
            {
                //int matches = content.BoyerMooreMatchCount(n.KeyWord);
                int matches = content.BoyerMooreMatchCount(" " + n.KeyWord + " ");
                if (matches > 0)
                {
                    for (int i = 0; i < matches; i++)
                    {
                        dataTree.AddConnection(n.KeyWord.Trim());
                    }
                }
            }
        }
예제 #2
0
        public void DocumentMapChangeBaseTree()
        {
            IBaseTree tree = setUpTree();

            IDataTree dataTree = DataTreeBuilder.CreateDocumentMappedTree(tree);

            DataTreeBuilder.AddAllToDataTree(dataTree, toMapEnumerable);

            dataTree.SetBaseTree(null);
            Assert.AreEqual(dataTree.GetBaseTree(), null);
        }
예제 #3
0
        internal StemmedDocumentMap(IDataTree tree)
        {
            baseTree  = tree.GetBaseTree();
            this.tree = tree;

            var         enumer = baseTree.GetEnumerator();
            List <Node> nodes  = new List <Node>();

            while (enumer.MoveNext())
            {
                nodes.Add((Node)enumer.Current);
            }
            for (int i = 0; i < nodes.Count; i++)
            {
                Node s = nodes[i];
                baseTree.Rename(s, StringFunctions.StemmedWord(s.KeyWord));
            }
        }
예제 #4
0
        public void SaveDataTreeTest()
        {
            ITreeIO   io       = new TreeIO();
            IBaseTree basetree = setUpBaseTree();
            IDataTree datatree = setUpDataTree(basetree);

            io.SaveDataTree(datatree, location);

            Assert.IsTrue(File.Exists(location));

            IDataTree loadedDatatree = io.LoadDataTree(location);

            Assert.AreNotSame(basetree, loadedDatatree);
            Assert.AreEqual(basetree.Root.KeyWord, loadedDatatree.Root.Keyword);

            Assert.IsNull(loadedDatatree.GetBaseTree());
            Assert.IsNotNull(datatree.GetBaseTree());
        }
예제 #5
0
 public IBaseTree GetBaseTree()
 {
     return(tree.GetBaseTree());
 }