Esempio n. 1
0
        public void Update()
        {
            title_trie = new TrieTree(false /* !case_sensitive */);

            foreach (Note note in manager.Notes)
            {
                title_trie.AddKeyword(note.Title, note);
            }
        }
Esempio n. 2
0
        public static void Main(string [] args)
        {
            string src = "bazar this is some foo, bar, and baz bazbarfoofoo bazbazarbaz end bazar";

            Logger.Log("Searching in '{0}':", src);

            TrieTree trie = new TrieTree(false);

            trie.AddKeyword("foo", "foo");
            trie.AddKeyword("bar", "bar");
            trie.AddKeyword("baz", "baz");
            trie.AddKeyword("bazar", "bazar");

            Logger.Log("Starting search...");
            foreach (TrieHit hit in trie.FindMatches(src))
            {
                Logger.Log("*** Match: '{0}' at {1}-{2}",
                           hit.Key,
                           hit.Start,
                           hit.End);
            }
            Logger.Log("Search finished!");
        }
		void UpdateTrie (bool refresh_query)
		{
			trie = new TrieTree (false /* !case_sensitive */);
			List<PersonLink> people = new List<PersonLink> ();

			Logger.Log ("Loading up the person trie, Part 1...");

			foreach (Person person in Galago.Global.GetPeople (Galago.Origin.Remote,
			                refresh_query)) {
				string name = person.DisplayName;

				if (name != null) {
					people.Add (new PersonLink (LinkType.PersonDisplayName, person));
				}

				foreach (Account account in person.GetAccounts(true)) {
					if (account.DisplayName != null) {
						people.Add (new PersonLink (LinkType.AccountDisplayName,
						                            account));
					}

					if (account.Username != null &&
					                account.Username != account.DisplayName) {
						people.Add (new PersonLink (LinkType.AccountUserName,
						                            account));
					}
				}
			}

			Logger.Log ("Loading up the person trie, Part 2...");

			foreach (PersonLink plink in people) {
				trie.AddKeyword (plink.LinkText, plink);
			}

			Logger.Log ("Done.");
		}