Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TrackedProjectsViewModel" /> class.
        /// </summary>
        /// <param name="projects">The projects.</param>
        public TrackedProjectsViewModel(IEnumerable <TrackedProjectViewModel> projects)
        {
            Ensure.That(projects).IsNotNull();

            Projects = projects.ToArray();

            _filteredProjects = new CollectionViewSource
            {
                Source = Projects
            };

            _filteredProjects.Filter += (sender, e) =>
            {
                var project = (TrackedProjectViewModel)e.Item;

                e.Accepted = _matches?.Contains(project) ?? true;
            };

            FilteredProjects = _filteredProjects.View;

            _trie = new SuffixTrie <TrackedProjectViewModel>(3);

            foreach (var project in Projects)
            {
                _trie.Add(project.Name.ToLowerInvariant(), project);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            ITrie <int> trie = new SuffixTrie <int>(2);

            BuildTrie("SomeBigTextFile.txt", trie);

            var wordCount = trie.Retrieve("array").ToArray();

            Console.WriteLine("The word 'array' occurs {0} times", wordCount.Length);
        }
Ejemplo n.º 3
0
        private void BuildTrackerConnectionProgressChanged(object sender, BuildTrackerConnectionProgressEventArgs e)
        {
            if (ShouldExitHandler(e))
            {
                return;
            }

            foreach (var project in e.Projects)
            {
                var projectToUpdate = _projects.SingleOrDefault(p => p.Id == project.Id);

                if (projectToUpdate != null)
                {
                    projectToUpdate.TryUpdate(project.Name);
                }
                else
                {
                    _application.Dispatcher.Invoke(() =>
                    {
                        var projectToAdd = _projectFactory.Create(SettingsId, project.Id, project.Name);

                        var names = _projects.Select(p => p.Name).Concat(new[] { projectToAdd.Name }).OrderBy(name => name).ToArray();

                        var index = Array.IndexOf(names, projectToAdd.Name);

                        _projects.Insert(index, projectToAdd);
                    });
                }
            }

            var projectsToKeep   = e.Projects.Select(project => project.Id).ToArray();
            var projectsToRemove = _projects.Where(project => !projectsToKeep.Contains(project.Id)).ToArray();

            if (_projects.Any())
            {
                _application.Dispatcher.Invoke(() =>
                {
                    _projects.RemoveRange(projectsToRemove);
                });
            }

            _trie = new SuffixTrie <IProjectViewModel>(3);

            foreach (var project in _projects)
            {
                _trie.Add(project.Name.ToLowerInvariant(), project);
            }

            IsErrored = false;
            IsBusy    = false;

            NotifyOfPropertyChange(() => HasProjects);
            NotifyOfPropertyChange(() => HasNoProjects);
            NotifyOfPropertyChange(() => IsViewable);
        }
        public static void Main()
        {
            ITrie<int> trie = new SuffixTrie<int>(3);

            // Read words from file
            var words = File.ReadAllText(InputFileName, Encoding.UTF8).Split(new[] { ' ' });

            //Look-up
            LookUp("много", trie);
            LookUp("се", trie);
            LookUp("така", trie);
        }
Ejemplo n.º 5
0
        public static void Main()
        {
            ITrie <int> trie = new SuffixTrie <int>(3);

            // Read words from file
            var words = File.ReadAllText(InputFileName, Encoding.UTF8).Split(new[] { ' ' });

            //Look-up
            LookUp("много", trie);
            LookUp("се", trie);
            LookUp("така", trie);
        }
Ejemplo n.º 6
0
        private static void Main(string[] args)
        {
            ITrie <int> trie = new SuffixTrie <int>(3);

            BuildUp("sample.txt", trie);

            //Look-up 5 words 200 times = 1000 searches
            for (int i = 0; i < 200; i++)
            {
                LookUp("has", trie);
                LookUp("the", trie);
                LookUp("is", trie);
                LookUp("as", trie);
                LookUp("a", trie);
            }
        }
Ejemplo n.º 7
0
        static void Main()
        {
            ITrie<int> trie = new SuffixTrie<int>(3);
            //You can replace it with other trie data structures too 
            //ITrie<int> trie = new Trie<int>();
            //ITrie<int> trie = new PatriciaSuffixTrie<int>(3);

            //Build-up
            BuildUp(@"../../texts/Peter Pan by J. M. Barrie.txt", trie);

            //Look-up
            LookUp("restrictions", trie);
            LookUp("whatsoever", trie);
            LookUp("expecting", trie);

            Console.WriteLine("-------------Press any key to quit--------------");
            Console.ReadKey();
        }
Ejemplo n.º 8
0
        static void Main()
        {
            ITrie <int> trie = new SuffixTrie <int>(3);

            //You can replace it with other trie data structures too
            //ITrie<int> trie = new Trie<int>();
            //ITrie<int> trie = new PatriciaSuffixTrie<int>(3);

            //Build-up
            BuildUp(@"../../texts/Peter Pan by J. M. Barrie.txt", trie);

            //Look-up
            LookUp("restrictions", trie);
            LookUp("whatsoever", trie);
            LookUp("expecting", trie);

            Console.WriteLine("-------------Press any key to quit--------------");
            Console.ReadKey();
        }
Ejemplo n.º 9
0
        private static void Main(string[] args)
        {
            var trie = new SuffixTrie <int>(3);

            //You can replace it with other trie data structures too
            //ITrie<int> trie = new Trie<int>();
            //ITrie<int> trie = new PatriciaSuffixTrie<int>(3);


            try
            {
                //Build-up
                BuildUp("sample.txt", trie);
                //Look-up
                LookUp("overs", trie);
                LookUp("porta", trie);
                LookUp("supercalifragilisticexpialidocious", trie);
            }
            catch (IOException ioException) { Console.WriteLine("Error: {0}", ioException.Message); }
            catch (UnauthorizedAccessException unauthorizedAccessException) { Console.WriteLine("Error: {0}", unauthorizedAccessException.Message); }

            Console.WriteLine("-------------Press any key to quit--------------");
            Console.ReadKey();
        }
Ejemplo n.º 10
0
        private static void Main(string[] args)
        {
            ITrie<int> trie = new SuffixTrie<int>(3);

            BuildUp("sample.txt", trie);

            //Look-up 5 words 200 times = 1000 searches
            for (int i = 0; i < 200; i++)
            {
                LookUp("has", trie);
                LookUp("the", trie);
                LookUp("is", trie);
                LookUp("as", trie);
                LookUp("a", trie);
            }
        }
Ejemplo n.º 11
0
 public SearchEngine(int minSuffixLength)
 {
     this.trie = new SuffixTrie <T>(minSuffixLength);
 }
        public void Testing()
        {
            var suffixTrie = new SuffixTrie();

            suffixTrie.Insert("Pokemon");
        }
Ejemplo n.º 13
0
 public void TestTrieCase(SuffixTrie trie, string substr, string[] expectedResults)
 {
     List<SubstringMatch> results;
     results = trie.FindSubstringMatches(substr);
     CheckTrieResults(results,expectedResults);
 }
Ejemplo n.º 14
0
        public void TestTrie()
        {
            SuffixTrie trie = new SuffixTrie();

            trie.AddString("cat");
            trie.AddString("catherine");
            trie.AddString("car");
            trie.AddString("cop");
            trie.AddString("transaction");
            trie.AddString("transvestite");
            trie.AddString("interview");
            trie.AddString("yogayoga!");

            TestTrieCase(trie, "abcd", new string[0]);
            TestTrieCase(trie, "c", new string[] { "cat", "catherine", "car", "cop", "transaction" } );
            TestTrieCase(trie, "e", new string[] { "catherine", "transvestite", "interview" });
            TestTrieCase(trie, "ca", new string[] { "cat", "catherine", "car" });
            TestTrieCase(trie, "cat", new string[] { "cat", "catherine" });
            TestTrieCase(trie, "cath", new string[] { "catherine" });
            TestTrieCase(trie, "catherine", new string[] { "catherine" });
            TestTrieCase(trie, "catherine1", new string[0]);
            TestTrieCase(trie, "caq", new string[0]);
            TestTrieCase(trie, "at", new string[] { "cat", "catherine" } );
            TestTrieCase(trie, "in", new string[] { "interview", "catherine" });
            TestTrieCase(trie, "yoga", new string[] { "yogayoga!" });
        }
Ejemplo n.º 15
0
        public static void DoTest2()
        {
            var tree = new SuffixTrie("bab");

            Assert.That(tree.Contains("bb"), Is.EqualTo(false));
        }
Ejemplo n.º 16
0
        public static void DoTest()
        {
            var tree = new SuffixTrie("babc");

            Assert.That(tree.Contains("bc"), Is.EqualTo(true));
        }