private static void DoInterestingAnalysis_GoogleScholar(PDFReadingControl pdf_reading_control, PDFRendererControl pdf_renderer_control, PDFRendererControlStats pdf_renderer_control_stats)
        {
#if true
            // Get the GoogleScholar similar documents
            try
            {
                string title = pdf_renderer_control_stats.pdf_document.TitleCombined;
                if (Constants.TITLE_UNKNOWN != title)
                {
                    GoogleScholarScrapePaperSet gssp_set = GoogleScholarScrapePaperSet.GenerateFromQuery(title, 10);

                    pdf_renderer_control.Dispatcher.Invoke(new Action(() =>
                    {
                        pdf_reading_control.SimilarDocsControl.SpecifyPaperSet(gssp_set);
                    }
                                                                      ));
                }
                else
                {
                    Logging.Info("We don't have a title, so skipping GoogleScholar similar documents");
                }
            }
            catch (Exception ex)
            {
                Logging.Error(ex, "There was a problem getting the GoogleScholar similar documents for document {0}", pdf_renderer_control_stats.pdf_document.Fingerprint);
            }
#endif
        }
Exemple #2
0
        private static void DoInterestingAnalysis_GoogleScholar(PDFReadingControl pdf_reading_control, PDFDocument pdf_document)
        {
            bool attempt_scrape = Qiqqa.Common.Configuration.ConfigurationManager.Instance.ConfigurationRecord.GoogleScholar_DoExtraBackgroundQueries;

            if (attempt_scrape)
            {
                Logging.Info("You are accessing Google Scholar in the background as you have the 'Send extra background queries to Google Scholar' Configuration option ticked. Be aware that this can lead to a quick denial of service response by Google in the form of a 40x HTTP Error or RECAPTCHA page instead of the search response you seek! Also refer to GitHub issues #225 & #113.");

                // Get the GoogleScholar similar documents
                try
                {
                    string title = pdf_document.TitleCombined;
                    if (Constants.TITLE_UNKNOWN != title)
                    {
                        GoogleScholarScrapePaperSet gssp_set = GoogleScholarScrapePaperSet.GenerateFromQuery(title, 10);

                        WPFDoEvents.InvokeAsyncInUIThread(() =>
                        {
                            pdf_reading_control?.SimilarDocsControl.SpecifyPaperSet(gssp_set);
                        });
                    }
                    else
                    {
                        Logging.Info("We don't have a title, so skipping GoogleScholar similar documents");
                    }
                }
                catch (Exception ex)
                {
                    Logging.Error(ex, "There was a problem getting the GoogleScholar similar documents for document {0}", pdf_document.Fingerprint);
                }
            }
        }
Exemple #3
0
        public void SpecifyPaperSet(GoogleScholarScrapePaperSet gssps)
        {
            DocsPanel.Children.Clear();

            {
                // Add the header
                StackPanel         sp    = new StackPanel();
                HyperlinkTextBlock tb_gs = new HyperlinkTextBlock();
                tb_gs.HorizontalAlignment = HorizontalAlignment.Center;
                tb_gs.Text       = "Go to GoogleScholar";
                tb_gs.FontWeight = FontWeights.Bold;
                tb_gs.Tag        = gssps.Url;
                tb_gs.OnClick   += OpenUrlInTagOfTextBlock;
                sp.Children.Add(tb_gs);
                DocsPanel.Children.Add(sp);
                DocsPanel.Children.Add(new AugmentedSpacer());
            }

            bool alternate = false;

            foreach (var gssp in gssps.Papers)
            {
                StackPanel sp = new StackPanel();

                try
                {
                    string html = gssp.abstract_html;
                    html = html.Replace("<br>", " ");
                    string       xaml = HtmlToXamlConverter.ConvertHtmlToXaml(html, true);
                    FlowDocument fd   = (FlowDocument)XamlReader.Parse(xaml);
                    RichTextBox  rtb  = new RichTextBox(fd);
                    rtb.Width  = 320;
                    rtb.Height = 200;
                    sp.ToolTip = rtb;
                }
                catch (Exception ex)
                {
                    Logging.Warn(ex, "Problem parsing GS HTML abstract");
                }

                if (null != gssp.source_url)
                {
                    HyperlinkTextBlock tb_title = new HyperlinkTextBlock();
                    tb_title.Text     = gssp.title;
                    tb_title.Tag      = gssp.source_url;
                    tb_title.OnClick += OpenUrlInTagOfTextBlock;
                    sp.Children.Add(tb_title);
                }
                else
                {
                    TextBlock tb_title = new TextBlock();
                    tb_title.Text       = gssp.title;
                    tb_title.FontWeight = FontWeights.Bold;
                    sp.Children.Add(tb_title);
                }

                TextBlock tb_authors = new TextBlock();
                tb_authors.Text = gssp.authors;
                sp.Children.Add(tb_authors);

                TextBlock tb_citedby = new TextBlock();
                tb_citedby.Text = gssp.cited_by_header;
                sp.Children.Add(tb_citedby);

                if (0 < DocsPanel.Children.Count)
                {
                    DocsPanel.Children.Add(new AugmentedSpacer());
                }

                alternate = !alternate;
                ListFormattingTools.AddGlowingHoverEffect(sp);

                DocsPanel.Children.Add(sp);
            }
        }