コード例 #1
0
    public static void Main()
    {
        string text = File.ReadAllText("../../text.txt").ToLower();
        int wordsCount = int.Parse(Console.ReadLine());
        string[] wordsOriginal = new string[wordsCount];
        string[] wordsLowerCase = new string[wordsCount];
        for (int i = 0; i < wordsCount; i++)
        {
            wordsOriginal[i] = Console.ReadLine();
            wordsLowerCase[i] = wordsOriginal[i].ToLower();
        }

        var occurances = new Dictionary<string, int>(wordsCount);
        foreach (string word in wordsLowerCase)
        {
            occurances[word] = 0;
        }

        var start = DateTime.Now;

        var search = new AhoCorasickSearch();
        var matches = search.SearchAll(text, wordsLowerCase);
        foreach (var match in matches)
        {
            string word = match.Match;
            occurances[word]++;
        }

        foreach (var wordOccurances in occurances)
        {
            Console.WriteLine("{0} -> {1}", wordOccurances.Key, wordOccurances.Value);
        }

        Console.WriteLine(DateTime.Now - start);
    }
コード例 #2
0
        private static void searchTest(AhoCorasickSearch search)
        {
            var res = search.SearchAll("ushersushers");

            Console.WriteLine(res);
            for (int i = 0; i < res.Length; i++)
            {
                Console.WriteLine(res[i].ToString());
                Console.WriteLine("Match=" + res[i].Match);
            }
        }
コード例 #3
0
    public static void Main()
    {
        string text       = File.ReadAllText("../../text.txt").ToLower();
        int    wordsCount = int.Parse(Console.ReadLine());

        string[] wordsOriginal  = new string[wordsCount];
        string[] wordsLowerCase = new string[wordsCount];
        for (int i = 0; i < wordsCount; i++)
        {
            wordsOriginal[i]  = Console.ReadLine();
            wordsLowerCase[i] = wordsOriginal[i].ToLower();
        }

        var occurances = new Dictionary <string, int>(wordsCount);

        foreach (string word in wordsLowerCase)
        {
            occurances[word] = 0;
        }

        var start = DateTime.Now;

        var search  = new AhoCorasickSearch();
        var matches = search.SearchAll(text, wordsLowerCase);

        foreach (var match in matches)
        {
            string word = match.Match;
            occurances[word]++;
        }


        foreach (var wordOccurances in occurances)
        {
            Console.WriteLine("{0} -> {1}", wordOccurances.Key, wordOccurances.Value);
        }

        Console.WriteLine(DateTime.Now - start);
    }
コード例 #4
0
ファイル: Program.cs プロジェクト: tupunco/Tup.AhoCorasick
 private static void searchTest(AhoCorasickSearch search)
 {
     var res = search.SearchAll("ushers");
     Console.WriteLine(res);
 }
コード例 #5
0
        private static void searchTest(AhoCorasickSearch search)
        {
            var res = search.SearchAll("ushers");

            Console.WriteLine(res);
        }