Exemplo n.º 1
0
        public YSearchResultCollection SearchWeb(String query, int offset, int limit, ref OmukSemantics semantics)
        {
            //semantics = new OmukSemantics();
            YSearchResultCollection resultCollection = new YSearchResultCollection();

            ysearchresponse ysearchResponse= this.ProcessRequest(query, offset, limit);
            resultCollection.NextPageUrl = ysearchResponse.nextpage;
            foreach (ysearchresponseResultset_webResult webResult in ysearchResponse.resultset_web.result)
            {
                resultCollection.SearchResult.Add(new YSearchItem()
                                                    {
                                                        AbstractText = webResult.@abstract,
                                                        Title = webResult.title,
                                                        UrlField = webResult.url
                                                    });
                semantics.ProcessContext(webResult.title, webResult.url, webResult.@abstract);
            }

            if (offset == 0)
            {
                if (semantics.Category.Equals("movie"))
                {
                    ysearchResponse = this.ProcessRequest(query + " rottentomatoes", 0, 4);
                    foreach (ysearchresponseResultset_webResult webResult in ysearchResponse.resultset_web.result)
                    {
                        if (webResult.url.StartsWith("http://www.rottentomatoes.com/m") || webResult.url.StartsWith("http://rottentomatoes.com/m"))
                        {
                            resultCollection.SearchResult.Insert(1, (new YSearchItem()
                            {
                                AbstractText = webResult.@abstract,
                                Title = webResult.title,
                                UrlField = webResult.url
                            }));
                        }
                    }
                }

            }

            return resultCollection;
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //NounCollection coll = NounCollection.Instance;
            //String [] related = null;
            //Console.WriteLine(coll.Nouns["hello"].GetDescription(0, out related));

            //using (StreamWriter writer = new StreamWriter(File.Create(@"\1.txt")))
            //{
            //    for (int index = 0; index < 256; index++)
            //        writer.WriteLine(String.Concat(index, " ", (char)index));
            //}
            //Console.WriteLine((int)'e');//'é');

            //BingSearch search = new BingSearch();
            //search.SearchWeb("apj kalam");

            //Wikipedia wClass = new Wikipedia(new WikiQueryEngine());
            //Console.WriteLine(wClass.IsArticleAvailable("Plain white T's"));
            //SearchSuggestion searchSuggest = wClass.SearchArticles("Plain white T's", 10);
            //foreach (SearchSuggestionItem sItem in searchSuggest.Section)
            //{
            //    Console.WriteLine(sItem.Text + "\n\t" + sItem.Description + "\n" + sItem.Url);
            //}
            //Console.WriteLine(wClass.GetArticle("Seattle", false).Introduction);

            OmukSemantics semantics = new OmukSemantics();
            //YSearch search = new YSearch();
            //YSearchResultCollection resCollection = search.SearchWeb("me genera serotonina listening to Viva la Vida by Coldplay", 0, 10, ref semantics);
            BingSearch bsearch = new BingSearch();
            bsearch.SearchWeb("Am I Dreaming by Xscape", 0, 10, ref semantics);
            semantics.PostSearch();
            semantics.FormContext();

            LyricWiki wiki = new LyricWiki();
            LyricsResult lyrics = wiki.getSong("Rihanna", "Umbrella");
            Console.WriteLine(lyrics.lyrics);
            //Console.WriteLine("");
            LastFmService service = new LastFmService();
            //service.GetArtistInfo(

            //MusicBrainz mb = new MusicBrainz();
               // mb.GetAlbums

            //Grooveshark gshark = new Grooveshark();
            //GSSong[] song = gshark.SearchSong("Sugar", 2);

            //LyricWiki wiki = new LyricWiki();
            //LyricsResult lyrics = wiki.getSong("R.e.m", "Moon river");
            //lyrics.GetLyricsHtml();
            //SongResult songs = wiki.searchSongs("R.e.m", "Moon river");

            //String artist = "Flo rida";
            //String album = "Sugar";
            //int year = 2009;
            //String[] albums = null;
            //String res = wiki.getAlbum(ref artist, ref album, ref year, out albums);

            //AlbumData[] album = (AlbumData[])wiki.getArtist(ref artist);
            //LWLyrics lyrics = wiki.GetLyricsForSong("Flo rida", "sugar");
            //Console.WriteLine(wiki.IsArtist("rihanna"));
            //String[] albums = wiki.GetAlbums("rihanna");

            //LastFmService service = new LastFmService();
            //LFMArtist artist = service.GetArtistInfo("Rihanna");
            //List<LFMArtist> albums = service.SearchArtist("Kid Cudi", 0);

            //Immem immem = new Immem();
            //List<ImmemSearchItem> items = immem.SearchMedia("Rihanna good girl gone bad", "music", 0, 10);

            MusicBrainz mb = new MusicBrainz();
            List<MBAlbum> albums = mb.GetAlbums(String.Empty, "Rihanna", "73e5e69d-3554-40d8-8516-00cb38737a1c", 0, 10);
            List<MBSong> songs = mb.GetSongs("oh Carol", "Neil", "", "", "", 0, 2);

            //YouTube yt = new YouTube();
            //List<YTVideo> videos = yt.SearchVideos("oh carol", 0, 3);

            //RottenTomatoes rt = new RottenTomatoes();
            //String val = rt.GetTomatometerScore("http://www.rottentomatoes.com/m/1009437-heidi/");

            /*
            Twitter twitter = new Twitter();
            ////twitter.SearchTwitter("i gotta feeling", 0, 10);
            TMovieTrendsClass mTrends = new TMovieTrendsClass();
            twitter.GetMovieTrends("The Martian", ref mTrends);
            Console.WriteLine("");
            */

            //twitter.GetMovieTrends("\"the proposal\"",ref mTrends);
            //twitter.GetMovieTrends("\"year one\"", ref mTrends);
            //twitter.GetMovieTrends("\"Terminator Salvation\"", ref mTrends);
            //twitter.GetMovieTrends("\"Next day air\"", ref mTrends);
            //twitter.GetMovieTrends("\"Imagine That\"", ref mTrends);
            //twitter.GetMovieTrends("\"Taking of Pelham 1 2 3", ref mTrends);
            //twitter.GetMovieTrends("Wolverine", ref mTrends);
            //using (StreamWriter writer = new StreamWriter(File.Create("trend.txt")))
            //{
            //    foreach (KeyValuePair<String, int> keyval in mTrends.Trend)
            //    {
            //        if (keyval.Value > 3)
            //            writer.WriteLine(String.Format("{0} {1}", keyval.Key, keyval.Value));
            //    }
            //}

            //TSearchResultCollection twRes = twitter.SearchTwitter("palm pre", 0, 15);

            //Eventful evntful = new Eventful ();
            //EventCollection coll = evntful.SearchEvents("San Jose", 0, 10);
            //Digg digg = new Digg();
            //List<DiggResult> res = digg.SearchDigg("Hello", 0, 10);
            return;
        }
Exemplo n.º 3
0
        private String AppID = "52447E790CBE691A81FDFF596A4A976B85715ED4"; //"52447E790CBE691A81FDFF596A4A976BB4FD39CD";

        #endregion Fields

        #region Methods

        public BingSearchItemCollection SearchWeb(String query, int offset, int limit, ref OmukSemantics semantics)
        {
            xsd.SearchResponse searchResponse = this.ProcessRequest(query, offset, limit);
            BingSearchItemCollection itemCollection = new BingSearchItemCollection();

            if (searchResponse.Errors != null && searchResponse.Errors.Length > 0)
            {
                foreach (xsd.SearchResponseErrors errors in searchResponse.Errors)
                {
                    itemCollection.Errors.Add(new BingSearchError()
                                                {
                                                    Code = errors.Error.Code,
                                                    HelpUrl = errors.Error.HelpUrl,
                                                    Message = errors.Error.Message,
                                                    Parameter = errors.Error.Parameter,
                                                    Value = errors.Error.Value
                                                });
                }
            }

            if (searchResponse.Web != null && searchResponse.Web.Results != null)
            {
                itemCollection.Offset = searchResponse.Web.Offset;
                itemCollection.Total = searchResponse.Web.Total;
                if (searchResponse.Web.Results.Length > 0)
                {
                    foreach (xsd.WebWebResult result in searchResponse.Web.Results)
                    {
                        String desc = String.IsNullOrEmpty(result.Description) ? String.Empty :
                                                                    result.Description.Replace("", "<b>").Replace("", "</b>");
                        String title = result.Title.Replace("", "<b>").Replace("", "</b>");
                        itemCollection.Results.Add(new BingSearchItem()
                                                    {
                                                        Description = desc,
                                                        DisplayUrl = result.DisplayUrl,
                                                        TimeField = result.DateTime,
                                                        Title = title,
                                                        UrlField = result.Url
                                                    });
                        semantics.ProcessContext(title, result.Url, desc);
                    }
                }
            }

            if (offset == 0)
            {
                if (semantics.Category.Equals("movie"))
                {
                    searchResponse = this.ProcessRequest(query + " rottentomatoes", 0, 4);
                    if (searchResponse.Web.Results.Length > 0)
                    {
                        foreach (xsd.WebWebResult result in searchResponse.Web.Results)
                        {
                            String desc = String.IsNullOrEmpty(result.Description) ? String.Empty :
                                                                        result.Description.Replace("", "<b>").Replace("", "</b>");
                            String title = result.Title.Replace("", "<b>").Replace("", "</b>");

                            if (result.Url.StartsWith("http://www.rottentomatoes.com/m") || result.Url.StartsWith("http://rottentomatoes.com/m"))
                            {
                                itemCollection.Results.Add(new BingSearchItem()
                                                            {
                                                                Description = desc,
                                                                DisplayUrl = result.DisplayUrl,
                                                                TimeField = result.DateTime,
                                                                Title = title,
                                                                UrlField = result.Url
                                                            });
                            }
                        }
                    }
                }
            }

            return itemCollection;
        }