private void OnSearch()
        {
            var results = WikiPediaService.Search(SearchText);

            SearchResults.Clear();
            foreach (var result in results)
            {
                SearchResults.Add(result);
            }
        }
Exemplo n.º 2
0
        public ActionResult Index(string category)
        {
            JsonpResult jr = new JsonpResult();

            jr.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            TypeItImage img = new TypeItImage();

            //go to wikipedia to get some data!
            if (category == null)
            {
                ViewBag.Message = "Your category is empty";
            }
            else if (category == "Test")
            {
                img.Src  = "http://paradoxoff.com/files/2012/12/hitachi-seaside-park-2.jpg";
                img.Word = "Flowers";
                jr.Data  = img;
                return(jr);
            }
            else   //real data
            {
                WikiPediaService srv        = new WikiPediaService();
                YoutubeService   youtubeSrv = new YoutubeService();

                //for example this will return for category = "dog"
                //["dog",["Dog","Doge of Venice","Dogma","Dog breed","Dogfight","Dogwood","Dog sled","Doge's Palace, Venice","Dog Day Afternoon","D\u014dgen"]]
                try
                {
                    List <WikiImage> imgs = srv.GetImages(category);

                    if (imgs.Count > 0)
                    {
                        img.Src  = imgs[0].Uri;
                        img.Word = imgs[0].Title;
                        //grab the reward video
                        img.RewardVideo = youtubeSrv.GetVideo(category);
                        jr.Data         = img;
                        return(jr);
                    }

                    ViewBag.Message = "No images were found! ";
                }
                catch (System.Exception ex)
                {
                    // System.Diagnostics.Debug.WriteLine(ex.Message);
                    ViewBag.Message = "There was an error! " + ex.Message;
                }
            }

            return(View());
        }
Exemplo n.º 3
0
        private static async void OnParse()
        {
            DateTime  startTime = DateTime.Now;
            Stopwatch stopWatch = Stopwatch.StartNew();

            Console.WriteLine("Opening Wikipedia stream...");

            // var uri = "https://dumps.wikimedia.org/enwiki/latest/enwiki-latest-abstract.xml";
            // var uri = "https://dumps.wikimedia.org/dewiki/20160305/dewiki-20160305-pages-meta-current2.xml-p000425451p001877043.bz2";
            // var uri = @"enwiki-latest-pages-articles.xml.bz2";
            // var uri = @"dewiki-20160305-pages-articles1.xml-p000000001p000425449.bz2";

            Console.WriteLine("Parsing & Indexing...");
            try
            {
                await WikiPediaService.ParseAsync(@"C:\Projects\GitHub\WikipediaDumpIndexer\Storages\dewiki-20160305-pages-articles1.xml-p000000001p000425449.bz2");

                Console.WriteLine("Done... Started: {0} Duration: {1}", startTime, stopWatch.Elapsed);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }