Пример #1
0
        private void ExpandThemes()
        {
            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Document_Themes);

            bool added_at_least_one_theme = false;

            if (null != pdf_document_node_content.PDFDocument.Library.ExpeditionManager)
            {
                ExpeditionDataSource eds = pdf_document_node_content.PDFDocument.Library.ExpeditionManager.ExpeditionDataSource;
                if (null != eds)
                {
                    if (eds.docs_index.ContainsKey(pdf_document_node_content.PDFDocument.Fingerprint))
                    {
                        int doc_id = eds.docs_index[pdf_document_node_content.PDFDocument.Fingerprint];
                        TopicProbability[] topics = eds.LDAAnalysis.DensityOfTopicsInDocsSorted[doc_id];

                        for (int t = 0; t < topics.Length && t < 5; ++t)
                        {
                            string           topic_name = eds.GetDescriptionForTopic(topics[t].topic, false, "\n");
                            ThemeNodeContent tnc        = new ThemeNodeContent(topic_name, pdf_document_node_content.PDFDocument.Library.WebLibraryDetail.Id);
                            NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, tnc, false);

                            added_at_least_one_theme = true;
                        }
                    }
                }
            }


            if (!added_at_least_one_theme)
            {
                MessageBoxes.Warn("There were no themes available for this document.  Please run Expedition against your library.");
            }
        }
        internal void ExploreTopicInBrainstorm(Library library, int topic)
        {
            ExpeditionDataSource eds = library.ExpeditionManager.ExpeditionDataSource;
            string topic_name        = eds.GetDescriptionForTopic(topic, false, "\n");

            BrainstormControl brainstorm_control = Instance.OpenNewBrainstorm();
            ThemeNodeContent  tnc          = new ThemeNodeContent(topic_name, library.WebLibraryDetail.Id);
            NodeControl       node_control = brainstorm_control.SceneRenderingControl.AddNewNodeControlInScreenCentre(tnc);

            brainstorm_control.AutoArrange = true;

            // Then expand the interesting documents - old style
            //ThemeNodeContentControl node_content_control = node_control.NodeContentControl as ThemeNodeContentControl;
            //node_content_control.ExpandSpecificDocuments();
            //node_content_control.ExpandInfluentialDocuments();

            // Then expand the interesting documents
            {
                // Thmeme docs
                brainstorm_control.SceneRenderingControl.SelectAll();
                brainstorm_control.SceneRenderingControl.RaiseEvent(new KeyEventArgs(Keyboard.PrimaryDevice, PresentationSource.FromVisual(brainstorm_control.SceneRenderingControl), 0, Key.D)
                {
                    RoutedEvent = Keyboard.KeyDownEvent
                });
                brainstorm_control.SceneRenderingControl.RaiseEvent(new KeyEventArgs(Keyboard.PrimaryDevice, PresentationSource.FromVisual(brainstorm_control.SceneRenderingControl), 0, Key.S)
                {
                    RoutedEvent = Keyboard.KeyDownEvent
                });

                // Authors
                brainstorm_control.SceneRenderingControl.SelectAll();
                brainstorm_control.SceneRenderingControl.RaiseEvent(new KeyEventArgs(Keyboard.PrimaryDevice, PresentationSource.FromVisual(brainstorm_control.SceneRenderingControl), 0, Key.A)
                {
                    RoutedEvent = Keyboard.KeyDownEvent
                });

                // Their docs
                brainstorm_control.SceneRenderingControl.SelectAll();
                brainstorm_control.SceneRenderingControl.RaiseEvent(new KeyEventArgs(Keyboard.PrimaryDevice, PresentationSource.FromVisual(brainstorm_control.SceneRenderingControl), 0, Key.D)
                {
                    RoutedEvent = Keyboard.KeyDownEvent
                });
            }

            brainstorm_control.SceneRenderingControl.SetSelectedNodeControl(node_control, false);
        }
Пример #3
0
        private static void ExpandThemes(PDFDocument doc, NodeControl node_control)
        {
            WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread();
            ASSERT.Test(doc != null);

            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Document_Themes);

            if (doc != null)
            {
                ASSERT.Test(doc.LibraryRef.Xlibrary != null);

                bool added_at_least_one_theme = false;

                ExpeditionDataSource eds = doc.LibraryRef.Xlibrary?.ExpeditionManager?.ExpeditionDataSource;
                if (null != eds)
                {
                    if (eds.docs_index.ContainsKey(doc.Fingerprint))
                    {
                        int doc_id = eds.docs_index[doc.Fingerprint];
                        TopicProbability[] topics = eds.LDAAnalysis.DensityOfTopicsInDocsSorted[doc_id];

                        WPFDoEvents.InvokeInUIThread(() =>
                        {
                            for (int t = 0; t < Math.Min(topics.Length, 5); ++t)
                            {
                                string topic_name    = eds.GetDescriptionForTopic(topics[t].topic, include_topic_number: false, "\n");
                                ThemeNodeContent tnc = new ThemeNodeContent(topic_name, doc.LibraryRef.Id);
                                NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, tnc, false);

                                added_at_least_one_theme = true;
                            }
                        });
                    }
                    else
                    {
                        Logging.Warn("Expedition has not been run for library '{0}'.", doc.LibraryRef.Title);
                    }
                }

                if (!added_at_least_one_theme)
                {
                    MessageBoxes.Warn("There were no themes available for this document.  Please run Expedition against your library.");
                }
            }
        }
        internal void ExploreLibraryInBrainstorm(Library library)
        {
            BrainstormControl brainstorm_control = Instance.OpenNewBrainstorm();

            int WIDTH  = 320;
            int HEIGHT = 240;

            LibraryNodeContent content_library = new LibraryNodeContent(library.WebLibraryDetail.Title, library.WebLibraryDetail.Id);
            NodeControl        node_library    = brainstorm_control.SceneRenderingControl.AddNewNodeControl(content_library, 0, 0, WIDTH, HEIGHT);

            ExpeditionDataSource eds = library.ExpeditionManager.ExpeditionDataSource;

            if (null != eds)
            {
                for (int topic = 0; topic < eds.lda_sampler.NumTopics; ++topic)
                {
                    string           topic_name = eds.GetDescriptionForTopic(topic, false, "\n");
                    ThemeNodeContent tnc        = new ThemeNodeContent(topic_name, library.WebLibraryDetail.Id);
                    NodeControlAddingByKeyboard.AddChildToNodeControl(node_library, tnc);
                }
            }
            else
            {
                {
                    StringNodeContent content_warning = new StringNodeContent("Please run Expedition on your library.");
                    NodeControl       node_warning    = brainstorm_control.SceneRenderingControl.AddNewNodeControl(content_warning, 0, -2 * HEIGHT);
                    brainstorm_control.SceneRenderingControl.AddNewConnectorControl(node_library, node_warning);
                }
                {
                    StringNodeContent content_warning = new StringNodeContent("Then you will get to\nexplore its themes.");
                    NodeControl       node_warning    = brainstorm_control.SceneRenderingControl.AddNewNodeControl(content_warning, -WIDTH, +2 * HEIGHT);
                    brainstorm_control.SceneRenderingControl.AddNewConnectorControl(node_library, node_warning);
                }
                {
                    StringNodeContent content_warning = new StringNodeContent("And you will get to\nexplore its documents.");
                    NodeControl       node_warning    = brainstorm_control.SceneRenderingControl.AddNewNodeControl(content_warning, +WIDTH, +2 * HEIGHT);
                    brainstorm_control.SceneRenderingControl.AddNewConnectorControl(node_library, node_warning);
                }
            }

            brainstorm_control.AutoArrange = true;
        }
        public static MultiMapSet <string, string> GetNodeItems_STATIC(Library library, HashSet <string> parent_fingerprints)
        {
            MultiMapSet <string, string> results = new MultiMapSet <string, string>();

            try
            {
                // Check that expedition has been run...
                if (null == library.ExpeditionManager || null == library.ExpeditionManager.ExpeditionDataSource)
                {
                    return(results);
                }

                ExpeditionDataSource eds = library.ExpeditionManager.ExpeditionDataSource;
                for (int t = 0; t < eds.LDAAnalysis.NUM_TOPICS; ++t)
                {
                    string topic_name = eds.GetDescriptionForTopic(t, false, "; ");

                    // Show the top % of docs
                    int num_docs = eds.LDAAnalysis.NUM_DOCS / 10;
                    num_docs = Math.Max(num_docs, 3);

                    for (int d = 0; d < eds.LDAAnalysis.NUM_DOCS && d < num_docs; ++d)
                    {
                        PDFDocument pdf_document = library.GetDocumentByFingerprint(eds.docs[eds.LDAAnalysis.DensityOfDocsInTopicsSorted[t][d].doc]);
                        if (null == parent_fingerprints || parent_fingerprints.Contains(pdf_document.Fingerprint))
                        {
                            results.Add(topic_name, pdf_document.Fingerprint);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.Error(ex, "There was a problem while loading the themes for the library explorer.");
            }

            return(results);
        }