Exemple #1
0
        public ResultList GSsearch(Query query)
        {
            //String queryURL = querybuilder.getURL
            //Result = parser.getResult

            //Dummy Results
            ResultList resultList = new ResultList();
            GSParser parser = new GSParser();

           resultList = parser.GSbuildQuery(query);
           /* Paper paper = new Paper();
            paper.settitle("A hybrid feature set based maximum entropy Hindi named entity recognition");
            paper.setdescription("hsjkasdhkjshjsak");
            paper.seturl(new Uri("http://google.co.in"));
            paper.setauthors("S Dandapat, S Sarkar, A Basu - Proceedings of the International …, 2004 - pdf.aminer.org");
            paper.setcitationsUrl("skhadkjshadksjdhkj");
            result.addPaper(paper);
            result.addPaper(paper);
            result.addPaper(paper);
            result.addPaper(paper);
            * */


           return resultList;
            //
          //  return null;            //TODO
        }
Exemple #2
0
        public ResultList MSASsearch(Query query)
        {
            ResultList resultList = new ResultList();
            MSASParser parser = new MSASParser();


            resultList = parser.MSASbuildQuery(query);
            return resultList;

        }
 public AddFavReturnCode addFavourite(Query query)
 {
     if (!inFavorites(query))
     {
         favourites.Add(query);
         if (writeFavouritesToFile())
             return AddFavReturnCode.ADDED;
         return AddFavReturnCode.NOT_ADDED;
     }
     return AddFavReturnCode.EXISTS;
 }
Exemple #4
0
        public ResultList GSbuildQuery(Query query)
        {

            GSQueryURLBuilder QB = new GSQueryURLBuilder();
            String URL = QB.buildQuery(query);
            this.query = query;

            var strUrl = new Uri(URL);



            int i;


            for (i = 0; i < 50; i += 10)
            {
                Result result = new Result();

                String newURL;
                newURL = strUrl + "&start=" + i.ToString();
                var newUrl = new Uri(newURL);
                Console.WriteLine(newUrl);
                result = GSConnect(newUrl);
                if (result != null)
                    this.resultList.Add(result);
                else
                    return null;

            }

            checkProfile(strUrl);

            return this.resultList;



        }
        public String buildQuery(Query query)
        {

            // sort by citations not implemented
            queryURL = String.Format("http://academic.research.microsoft.com/json.svc/search?AppId={0}&ResultObjects={1}&PublicationContent={2}", appId,"Publication","AllInfo");
            String searchString = null;
            searchString = query.getqueryString();

            searchString = searchString.Replace(" ", "+");

            if (query.resultType == ResultType.AUTHOR)
            {
                queryURL+="&AuthorQuery="+searchString;
            }

            else if (query.resultType == ResultType.JOURNAL)
            {
                queryURL += "&JournalQuery=" + searchString;
            }

            //sort by citations
            if (query.sortOrder == SortOrder.CITATIONS)
            {
                queryURL += "&OrderBy=CitationCount";
            }
            else if(query.sortOrder==SortOrder.DATE)
            {
                queryURL += "&OrderBy=Year";
            }

            //search for custom year range and sorted by citations
            if (query.issetylo())
            {
                queryURL += "&YearStart=" + query.getylo();
            }
            if (query.issetyhi())
            {
                queryURL += "&YearEnd=" + query.getyhi();
            }

            String pageStart = ((query.getpageid() -1)*20 + 1).ToString();
            queryURL += "&StartIdx=" + pageStart;

            String pageEnd = (query.getpageid()*20).ToString(); 
            queryURL += "&EndIdx=" + pageEnd;
            
            //search for custome year range and sorted by date
            //TODO : Need to get the correct URL.
            // #Srikar
            Console.WriteLine("::::::::"+queryURL);
            return queryURL;
        }
        public String buildQuery(Query query)
        {
            //normal search (sort by citations)
            // sort by citations not implemented
            String queryURL, queryURLStat1, queryURLStat2;
            queryURL = null;
            String queryPart1 = "http://scholar.google.co.in/scholar?as_q=&as_occt=any&";
            String searchString = null;
            searchString = query.getqueryString();

            searchString = searchString.Replace(" ", "+");

            if (query.resultType == ResultType.AUTHOR)
            {
                queryPart1 = queryPart1 + "as_sauthors=" + "\"" + searchString + "\"";
            }

            else if (query.resultType == ResultType.JOURNAL)
            {
                queryPart1 = queryPart1 + "as_publication=" + "\"" + searchString + "\"";
            }

            int patentChoice;
            String queryPart2 = "&hl=en&as_sdt=";
            if (!query.getincludePatents())
                patentChoice = 0;
            else
                patentChoice = 1;
            queryPart2 += patentChoice;
            queryPart2 += "%2C5&as_vis=1";

            //sort by citations
            if (query.sortOrder == SortOrder.CITATIONS && (query.issetyhi() && query.issetylo()))
            {
                queryURL = queryPart1 + queryPart2;
                queryURLStat1 = queryURL;
            }

            //sort by date
            else if (query.sortOrder == SortOrder.CITATIONS && !(query.issetyhi() && query.issetylo()))
            {
                int year = 2013;
                queryURL = queryPart1 + "&as_ylo=&as_yhi=" + queryPart2;
                year--;


            }

            //search for custom year range and sorted by citations
            else if ((query.issetyhi() && query.issetylo()) && query.sortOrder == SortOrder.CITATIONS)
            {

                queryURL = queryPart1 + "&as_ylo=" + query.getylo() + "&as_yhi=" + query.getyhi() + queryPart2;
                queryURLStat2 = queryURL;
            }

            //search for custome year range and sorted by date
            else if (query.sortOrder == SortOrder.DATE && (query.issetyhi() && query.issetylo()))
            {
                queryURL = queryPart1 + "&as_ylo=" + query.getylo() + "&as_yhi=" + query.getyhi() + queryPart2;
            }

            else if (query.sortOrder == SortOrder.DATE && !(query.issetyhi() && query.issetylo()))
            {
                queryURL = queryPart1 + "&as_ylo=&as_yhi=" + queryPart2;
            }

            //TODO : Need to get the correct URL.
            // #Srikar


            return queryURL;
        }
        public ResultList initiateSearch(data d)
        {
            String queryString = d.qs;
                       //tab.getSearchBoxText();
            if (d.b.CancellationPending)
            {
                return null;
            }
            if (queryString == null || queryString == "")
                   {
                       TabPage.displayError("Please Enter a Query");
                       return null;
                   }
                   
                   d.b.ReportProgress(0, null);
                   int ylo = d.yl;
                   int yhi = d.yh;  //tab.getYhi();
                   Boolean includeCitations = d.ic;  // tab.getIncludePatents();
                   SortOrder sortOrder = d.so;  //tab.getSortOrder();
                   ResultType resultType = d.rt; // tab.getResultType();

                   d.b.ReportProgress(10, null);
                   Query query = new Query();
                   query.setqueryString(queryString);
                   if (ylo != 0)
                       query.setylo(ylo);
                   if (yhi != 0)
                       query.setyhi(yhi);
                   query.setincludePatents(includeCitations);
                   query.sortOrder = sortOrder;
                   query.resultType = resultType;
                   query.setpageid(d.pageId);

                   if (d.b.CancellationPending)
                   {
                       return null;
                   }

                   //bool networkUp = System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable();
                   bool networkUp = Controller.CheckForInternetConnection();
                   Console.WriteLine(networkUp);
                   if (networkUp)
                   {
                       Searcher searcher = new Searcher();
                       ResultList resultListGS = new ResultList();

                       ResultList resultListMS = new ResultList();

                       ResultList resultList = new ResultList();


                       SearchType type;
                       d.b.ReportProgress(20, null);
                       resultListGS = searcher.GSsearch(query);
                       if (d.b.CancellationPending)
                       {
                           return null;
                       }
                       d.b.ReportProgress(50, null);
                       resultListMS = searcher.MSASsearch(query);
                       if (d.b.CancellationPending)
                       {
                           return null;
                       }
                       d.b.ReportProgress(70, null);

                       if (resultListMS != null)
                           resultList = resultListMS;
                       else if (resultListMS == null && resultListGS != null)
                           resultList = resultListGS;
                       else
                       {
                           TabPage.displayError("Cannot connect to Data Sources.");
                           return null;
                       }
                       if (d.b.CancellationPending)
                       {
                           return null;
                       }

                       d.b.ReportProgress(85, null);

                       if (resultListGS != null)
                       {
                           if (resultListGS.type != null)
                           resultList.type = resultListGS.type;
                           
                       }
                       else
                       {
                           MSASQueryURLBuilder MSQ = new MSASQueryURLBuilder();
                           String URL = "";
                           if (resultType == ResultType.AUTHOR)
                           {
                               URL = MSQ.buildAuthorUrl(queryString);
                           }
                           else if (resultType == ResultType.JOURNAL)
                           {
                               URL = MSQ.buildJournalUrl(queryString);
                           }
                           
                           Uri url = new Uri(URL);
                           Console.WriteLine(url.ToString());
                           MSASParser parser = new MSASParser();
                           if (resultType == ResultType.AUTHOR)
                           {
                               resultList.resultType = ResultType.AUTHOR;
                               resultList.type = parser.MSParseProfile(url, queryString, resultType);
                           }
                           else
                           {
                               resultList.resultType = ResultType.JOURNAL;
                               resultList.loadType();
                               Console.WriteLine("Reached");
                               resultList.type =(Journal) parser.MSParseJournal(queryString);
                               Console.WriteLine(";;;;;"+resultList.type);
                           }
                           if (d.b.CancellationPending)
                           {
                               return null;
                           }

                       }

                       //      tab.setResult(resultList);    

                       if (d.b.CancellationPending)
                       {
                           
                           return null;
                       }

                       d.b.ReportProgress(100, null);
                       return resultList;
                   }

                   else
                   {
                       TabPage.displayError("Oops !! No Internet Connection !!!");

                       return null;

                   }
        }
Exemple #8
0
 public Boolean Equals(Query q)
 {
     if (!(queryString.Equals(q.getqueryString())))
         return false;
     if (!(ylo.Equals(q.getylo())))
         return false;
     if (!(yhi.Equals(q.getyhi())))
         return false;
     if (!(includePatents.Equals(q.getincludePatents())))
         return false;
     if (!(id.Equals(q.getpageid())))
         return false;
     if (!(sortOrder.Equals(q.sortOrder)))
         return false;
     if (!(resultType.Equals(q.resultType)))
         return false;
     return true;
 }
Exemple #9
0
        public ResultList MSASbuildQuery(Query query)
        {

            MSASQueryURLBuilder MSB = new MSASQueryURLBuilder();
            String URL = MSB.buildQuery(query);
            this.query = query;

            var strUrl = new Uri(URL);
            Console.WriteLine(URL);
            this.resultList.resultType = query.resultType;
            this.resultList.loadType();
            this.resultList = MSASConnectFetch(strUrl);
            return this.resultList;


        }
 private bool inFavorites(Query q)
 {
     foreach (Query query in favourites)
     {
         if (query.Equals(q))
             return true;
     }
     return false;
 }
 public Boolean deleteFavourite(Query query)
 {
     if (favourites.Remove(query))
         return writeFavouritesToFile();
     return false;
 }
 public void setSearch(Query q)
 {
     this.q = q ;
 }
        public TabPage(MainWindow mw, Favourites f, Query q)
        {
            this.mw = mw;
            this.f = f;
            this.q = q;
            InitializeComponent();

            this.Searcher = new System.ComponentModel.BackgroundWorker();
            this.Searcher.WorkerReportsProgress = true;
            this.Searcher.WorkerSupportsCancellation = true;


            this.Searcher.DoWork += new System.ComponentModel.DoWorkEventHandler(this.Searcher_DoWork);
            this.Searcher.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.Searcher_ProgressChanged);
            this.Searcher.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.Searcher_RunWorkerCompleted);


            this.viewCitation = new System.ComponentModel.BackgroundWorker();
            this.viewCitation.WorkerReportsProgress = true;
            this.viewCitation.WorkerSupportsCancellation = true;
            this.viewCitation.DoWork += new System.ComponentModel.DoWorkEventHandler(this.Citation_DoWork);
            this.viewCitation.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.Citation_ProgressChanged);
            this.viewCitation.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.Citation_RunWorkerCompleted);
            controllerList = new List<Controller>();

            progressBar.Visibility = System.Windows.Visibility.Hidden;
            this.searchBox.Opacity = 1;


            this.UpdateStatusBar += updateStatusBar;  // related to statusbar

            updateStatusBar("Ready To Search !!!");

            this.searchBox.Text = q.getqueryString();
            if (q.resultType == ResultType.AUTHOR)
            {
                this.radioAuthor.IsChecked = true;
                this.radioJournal.IsChecked = false;
            }
            else
            {
                this.radioJournal.IsChecked = true;
                this.radioAuthor.IsChecked = false;
            }
            if (q.sortOrder == SortOrder.CITATIONS)
            {
                this.radioCitations.IsChecked = true;
                this.radioDate.IsChecked = false;
            }
            else
            {
                this.radioDate.IsChecked = true;
                this.radioCitations.IsChecked = false;
            }
            int flag = 0;
            if (q.issetyhi())
            {
                flag = 1;
                this.checkBoxCustomRange.IsChecked = true;
                this.checkBoxCustomRange.IsEnabled = true;
                this.yearEnd.IsEnabled = true;
                this.yearStart.IsEnabled = true;
                this.yearEnd.Text = q.getyhi() + "";
            }
            if (q.issetylo())
            {
                flag = 1;
                this.checkBoxCustomRange.IsChecked = true;
                this.checkBoxCustomRange.IsEnabled = true;
                this.yearEnd.IsEnabled = true;
                this.yearStart.IsEnabled = true;
                this.yearStart.Text = q.getylo() + "";
            }
            if (flag == 0)
                this.checkBoxCustomRange.IsChecked = false;
            currentPageSelected = q.getpageid();
            searchFav();

        }
 private void addFav(object sender, RoutedEventArgs e)
 {
     btnAddFav.Background = new SolidColorBrush(Color.FromRgb(71, 135, 237));
     btnAddFav.BorderBrush = new SolidColorBrush(Colors.DarkGray);
     btnAddFav.BorderThickness = new Thickness(1);
     btnAddFav.Content = "Favourite";
     btnAddFav.Foreground = new SolidColorBrush(Colors.White);
     Query q = new Query();
     q.setqueryString(this.getSearchBoxText());
     q.setyhi(this.getYhi());
     q.setylo(this.getYlo());
     if (this.getSortOrder() == SortOrder.DATE)
         q.sortOrder = SortOrder.DATE;
     else
         q.sortOrder = SortOrder.CITATIONS;
     if (this.getResultType() == ResultType.AUTHOR)
         q.resultType = ResultType.AUTHOR;
     else
         q.resultType = ResultType.JOURNAL;
     q.setpageid(currentPageSelected);
     fav.addFavourite(q);
 }