예제 #1
0
        private void GetAllWords(int length)
        {
            const string AllWordsAddressFormat = "http://www.listesdemots.fr/mots{0}lettres.htm";
            string       content = null;

            try
            {
                content = wc.DownloadString(string.Format(CultureInfo.InvariantCulture, AllWordsAddressFormat, length));
            }
            catch (WebException)
            {
            }
            if (content != null)
            {
                WordContent parsed = ParseContent(content);
                if (parsed.IsFull)
                {
                    allWords.AddRange(parsed.Words);
                }
                else
                {
                    for (char first = 'A'; first <= 'Z'; first++)
                    {
                        GetAllWords(length, first);
                    }
                }
                Console.WriteLine(length);
            }
        }
예제 #2
0
        private void GetAllWords(int length, char first, char second)
        {
            const string SecondAddressFormat = "http://www.listesdemots.fr/d/{1}/2/mots{0}lettresdebutant{1}{2}.htm";
            string       content             = null;

            try
            {
                content = wc.DownloadString(string.Format(CultureInfo.InvariantCulture, SecondAddressFormat, length, first, second));
            }
            catch (WebException)
            {
            }
            if (content != null)
            {
                WordContent parsed = ParseContent(content);
                if (parsed.IsFull)
                {
                    allWords.AddRange(parsed.Words);
                }
                else
                {
                    throw new NotImplementedException();
                }
                Console.WriteLine(length + first.ToString() + second.ToString());
            }
        }
예제 #3
0
        private void GetAllWords(int length, char first)
        {
            const string FirstAddressFormat = "http://www.listesdemots.fr/d/{1}/1/mots{0}lettresdebutant{1}.htm";
            string       content            = null;

            try
            {
                content = wc.DownloadString(string.Format(CultureInfo.InvariantCulture, FirstAddressFormat, length, first));
            }
            catch (WebException)
            {
            }
            if (content != null)
            {
                WordContent parsed = ParseContent(content);
                if (parsed.IsFull)
                {
                    allWords.AddRange(parsed.Words);
                }
                else
                {
                    for (char second = 'A'; second <= 'Z'; second++)
                    {
                        GetAllWords(length, first, second);
                    }
                }
                Console.WriteLine(length + first.ToString());
            }
        }
예제 #4
0
        [Test] public void TestParseContentCN()
        {
            const string ResourcePath = "Ded.Wordox.Resources.";
            var          resources    = new AssemblyResources(typeof(WordDownloaderTest), ResourcePath);
            string       content      = resources.GetContent("mots9lettresdebutantcn.htm");
            WordContent  wc           = WordDownloader.ParseContent(content);

            Assert.AreEqual(1, wc.Count);
            Assert.AreEqual(1, wc.Words.Count);
            Assert.IsTrue(wc.IsFull);
            foreach (string w in wc.Words)
            {
                Assert.AreEqual(9, w.Length);
            }
        }
예제 #5
0
        [Test] public void TestParseContent6()
        {
            const string ResourcePath = "Ded.Wordox.Resources.";
            var          resources    = new AssemblyResources(typeof(WordDownloaderTest), ResourcePath);
            string       content      = resources.GetContent("mots6lettres.htm");
            WordContent  wc           = WordDownloader.ParseContent(content);

            Assert.AreEqual(17318, wc.Count);
            Assert.AreEqual(17318 - 10175, wc.Words.Count);
            Assert.IsFalse(wc.IsFull);
            foreach (string w in wc.Words)
            {
                Assert.AreEqual(6, w.Length);
            }
        }