示例#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.");
            }
        }
示例#2
0
        internal static void AddDocumentsSimilarToDistribution(NodeControl node_control_, WebLibraryDetail web_library_detail, ExpeditionDataSource eds, float[] tags_distribution)
        {
            WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread();
            ASSERT.Test(eds != null);

            // Get the most similar PDFDocuments
            int[] doc_ids = LDAAnalysisTools.GetDocumentsSimilarToDistribution(eds.LDAAnalysis, tags_distribution);

            WPFDoEvents.InvokeInUIThread(() =>
            {
                WPFDoEvents.AssertThisCodeIsRunningInTheUIThread();

                for (int i = 0; i < 10 && i < doc_ids.Length; ++i)
                {
                    int doc_id         = doc_ids[i];
                    string fingerprint = eds.docs[doc_id];

                    PDFDocument pdf_document = web_library_detail.Xlibrary.GetDocumentByFingerprint(fingerprint);
                    if (null == pdf_document)
                    {
                        Logging.Warn("Couldn't find similar document with fingerprint {0}", fingerprint);
                    }
                    else
                    {
                        PDFDocumentNodeContent content = new PDFDocumentNodeContent(pdf_document.Fingerprint, pdf_document.LibraryRef.Id);
                        NodeControlAddingByKeyboard.AddChildToNodeControl(node_control_, content, false);
                    }
                }
            });
        }
示例#3
0
        void NodeControl_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            //Logging.Info("NodeControl_PreviewKeyDown");

            if (false)
            {
            }

            else if (Key.Insert == e.Key)
            {
                NodeControl node_control = (NodeControl)sender;

                if (KeyboardTools.IsCTRLDown())
                {
                    object content = new StringNodeContent("Child node");
                    NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, content);
                }
                else
                {
                    NodeControlAddingByKeyboard.AddSiblingToNodeControl(node_control);
                }

                e.Handled = true;
            }
        }
示例#4
0
        private static void ExpandCitationsOutbound(PDFDocument doc, NodeControl node_control)
        {
            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Document_CitationsOutbound);
            ASSERT.Test(doc != null);

            if (doc != null)
            {
                List <Citation> citations = doc.PDFDocumentCitationManager.GetOutboundCitations();

                WPFDoEvents.InvokeInUIThread(() =>
                {
                    WPFDoEvents.AssertThisCodeIsRunningInTheUIThread();

                    foreach (var citation in citations)
                    {
                        // NB: We assume the citations are from the same library!!
                        PDFDocumentNodeContent content = new PDFDocumentNodeContent(citation.fingerprint_inbound, doc.LibraryRef.Id);
                        if (!content.PDFDocument.Deleted)
                        {
                            NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, content, false);
                        }
                    }
                });
            }
        }
示例#5
0
        private static void ExpandAuthors(PDFDocument doc, NodeControl node_control)
        {
            WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread();
            ASSERT.Test(doc != null);

            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Document_Authors);

            if (doc != null)
            {
                string authors = doc.AuthorsCombined;
                if (String.IsNullOrEmpty(authors) || Constants.UNKNOWN_AUTHORS == authors)
                {
                    return;
                }

                WPFDoEvents.InvokeInUIThread(() =>
                {
                    WPFDoEvents.AssertThisCodeIsRunningInTheUIThread();

                    List <NameTools.Name> names = new List <NameTools.Name>();
                    string[] authors_split      = NameTools.SplitAuthors_LEGACY(authors);
                    foreach (string author_split in authors_split)
                    {
                        string first_names, last_name;
                        NameTools.SplitName_LEGACY(author_split, out first_names, out last_name);
                        string initial = String.IsNullOrEmpty(first_names) ? null : first_names.Substring(0, 1);
                        PDFAuthorNodeContent pdf_author = new PDFAuthorNodeContent(doc.LibraryRef.Id, last_name, initial);
                        NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, pdf_author, false);
                    }
                });
            }
        }
示例#6
0
        private void ExpandAuthors()
        {
            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Document_Authors);

            PDFDocument pdf_document = pdf_document_node_content.PDFDocument;

            string authors = pdf_document.AuthorsCombined;

            if (String.IsNullOrEmpty(authors) || 0 == PDFDocument.UNKNOWN_AUTHORS.CompareTo(authors))
            {
                return;
            }

            List <NameTools.Name> names = new List <NameTools.Name>();

            string[] authors_split = NameTools.SplitAuthors_LEGACY(authors);
            foreach (string author_split in authors_split)
            {
                string first_names, last_name;
                NameTools.SplitName_LEGACY(author_split, out first_names, out last_name);
                string initial = String.IsNullOrEmpty(first_names) ? null : first_names.Substring(0, 1);
                PDFAuthorNodeContent pdf_author = new PDFAuthorNodeContent(pdf_document.Library.WebLibraryDetail.Id, last_name, initial);
                NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, pdf_author, false);
            }
        }
示例#7
0
        private static void ExpandAnnotations(PDFDocument doc, NodeControl node_control)
        {
            WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread();
            ASSERT.Test(doc != null);

            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Document_Annotations);

            if (doc != null)
            {
                var annotations = doc.GetAnnotations();

                WPFDoEvents.InvokeInUIThread(() =>
                {
                    WPFDoEvents.AssertThisCodeIsRunningInTheUIThread();

                    foreach (var annotation in annotations)
                    {
                        if (!annotation.Deleted)
                        {
                            PDFAnnotationNodeContent content = new PDFAnnotationNodeContent(doc.LibraryRef.Id, doc.Fingerprint, annotation.Guid.Value);
                            NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, content, false);
                        }
                    }
                });
            }
        }
示例#8
0
        private void ExpandDocuments()
        {
            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Author_Documents);

            List <PDFDocument> pdf_documents = SimilarAuthors.GetDocumentsBySameAuthorsSurnameAndInitial(pdf_author_node_content.LibraryRef, pdf_author_node_content.Surname, pdf_author_node_content.Initial);

            foreach (PDFDocument pdf_document in pdf_documents)
            {
                PDFDocumentNodeContent content = new PDFDocumentNodeContent(pdf_document.Fingerprint, pdf_document.LibraryRef.Id);
                NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, content, false);
            }
        }
示例#9
0
        private void ExpandTags()
        {
            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Document_Tags);

            PDFDocument pdf_document = pdf_document_node_content.PDFDocument;

            foreach (string tag in TagTools.ConvertTagBundleToTags(pdf_document.Tags))
            {
                PDFTagNodeContent pdf_tag = new PDFTagNodeContent(pdf_document.Library.WebLibraryDetail.Id, tag);
                NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, pdf_tag, false);
            }
        }
示例#10
0
        private void ExpandRelevants()
        {
            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Document_Similars);

            List <ExpeditionPaperSuggestions.Result> results = ExpeditionPaperSuggestions.GetRelevantOthers(pdf_document_node_content.PDFDocument, 10);

            foreach (ExpeditionPaperSuggestions.Result result in results)
            {
                PDFDocumentNodeContent content = new PDFDocumentNodeContent(result.pdf_document.Fingerprint, result.pdf_document.Library.WebLibraryDetail.Id);
                NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, content, false);
            }
        }
示例#11
0
        public void ExpandDocuments()
        {
            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Tag_Documents);

            List <PDFDocument> pdf_documents = pdf_tag_node_content.Library.GetDocumentsByTag(pdf_tag_node_content.Tag);

            foreach (PDFDocument pdf_document in pdf_documents)
            {
                PDFDocumentNodeContent content = new PDFDocumentNodeContent(pdf_document.Fingerprint, pdf_document.Library.WebLibraryDetail.Id);
                NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, content, false);
            }
        }
示例#12
0
        private void ExpandAnnotations()
        {
            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Document_Annotations);

            foreach (var annotation in pdf_document_node_content.PDFDocument.Annotations)
            {
                if (!annotation.Deleted)
                {
                    PDFAnnotationNodeContent content = new PDFAnnotationNodeContent(pdf_document_node_content.PDFDocument.Library.WebLibraryDetail.Id, pdf_document_node_content.PDFDocument.Fingerprint, annotation.Guid.Value);
                    NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, content, false);
                }
            }
        }
示例#13
0
        private void ExpandAutoTags()
        {
            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Document_AutoTags);

            PDFDocument pdf_document = pdf_document_node_content.PDFDocument;

            HashSet <string> tags = pdf_document.Library.AITagManager.AITags.GetTagsWithDocument(pdf_document.Fingerprint);

            foreach (string tag in tags)
            {
                PDFAutoTagNodeContent pdf_auto_tag = new PDFAutoTagNodeContent(pdf_document.Library.WebLibraryDetail.Id, tag);
                NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, pdf_auto_tag, false);
            }
        }
示例#14
0
        private void ExpandCitationsInbound()
        {
            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Document_CitationsInbound);

            List <Citation> citations = pdf_document_node_content.PDFDocument.PDFDocumentCitationManager.GetInboundCitations();

            foreach (var citation in citations)
            {
                PDFDocumentNodeContent content = new PDFDocumentNodeContent(citation.fingerprint_outbound, pdf_document_node_content.PDFDocument.Library.WebLibraryDetail.Id);
                if (!content.PDFDocument.Deleted)
                {
                    NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, content, false);
                }
            }
        }
示例#15
0
        public void ExpandDocuments()
        {
            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_AutoTag_Documents);

            WebLibraryDetail web_library_detail = WebLibraryManager.Instance.GetLibrary(pdf_auto_tag_node_content.LibraryId);

            HashSet <string>   document_fingerprints = web_library_detail.Xlibrary.AITagManager.AITags.GetDocumentsWithTag(pdf_auto_tag_node_content.Tag);
            List <PDFDocument> pdf_documents         = web_library_detail.Xlibrary.GetDocumentByFingerprints(document_fingerprints);

            foreach (PDFDocument pdf_document in pdf_documents)
            {
                PDFDocumentNodeContent content = new PDFDocumentNodeContent(pdf_document.Fingerprint, pdf_document.LibraryRef.Id);
                NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, content, false);
            }
        }
示例#16
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;
        }
        internal static void AddDocumentsSimilarToDistribution(NodeControl node_control_, Library library, ExpeditionDataSource eds, float[] tags_distribution)
        {
            // Get the most similar PDFDocuments
            int[] doc_ids = LDAAnalysisTools.GetDocumentsSimilarToDistribution(eds.LDAAnalysis, tags_distribution);

            for (int i = 0; i < 10 && i < doc_ids.Length; ++i)
            {
                int    doc_id      = doc_ids[i];
                string fingerprint = eds.docs[doc_id];

                PDFDocument pdf_document = library.GetDocumentByFingerprint(fingerprint);
                if (null == pdf_document)
                {
                    Logging.Warn("Couldn't find similar document with fingerprint {0}", fingerprint);
                }
                else
                {
                    PDFDocumentNodeContent content = new PDFDocumentNodeContent(pdf_document.Fingerprint, pdf_document.Library.WebLibraryDetail.Id);
                    NodeControlAddingByKeyboard.AddChildToNodeControl(node_control_, content, false);
                }
            }
        }
示例#19
0
        private static void ExpandAutoTags(PDFDocument doc, NodeControl node_control)
        {
            WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread();
            ASSERT.Test(doc != null);

            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Document_AutoTags);

            if (doc != null)
            {
                HashSet <string> tags = doc.LibraryRef.Xlibrary.AITagManager.AITags.GetTagsWithDocument(doc.Fingerprint);

                WPFDoEvents.InvokeInUIThread(() =>
                {
                    WPFDoEvents.AssertThisCodeIsRunningInTheUIThread();

                    foreach (string tag in tags)
                    {
                        PDFAutoTagNodeContent pdf_auto_tag = new PDFAutoTagNodeContent(doc.LibraryRef.Id, tag);
                        NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, pdf_auto_tag, false);
                    }
                });
            }
        }
示例#20
0
        private static void ExpandTags(PDFDocument doc, NodeControl node_control)
        {
            WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread();
            ASSERT.Test(doc != null);

            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Document_Tags);

            if (doc != null)
            {
                var tags = TagTools.ConvertTagBundleToTags(doc.Tags);

                WPFDoEvents.InvokeInUIThread(() =>
                {
                    WPFDoEvents.AssertThisCodeIsRunningInTheUIThread();

                    foreach (string tag in tags)
                    {
                        PDFTagNodeContent pdf_tag = new PDFTagNodeContent(doc.LibraryRef.Id, tag);
                        NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, pdf_tag, false);
                    }
                });
            }
        }
示例#21
0
        private static void ExpandRelevants(PDFDocument doc, NodeControl node_control)
        {
            WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread();
            ASSERT.Test(doc != null);

            FeatureTrackingManager.Instance.UseFeature(Features.Brainstorm_ExploreLibrary_Document_Similars);

            if (doc != null)
            {
                List <ExpeditionPaperSuggestions.Result> results = ExpeditionPaperSuggestions.GetRelevantOthers(doc, 10);

                WPFDoEvents.InvokeInUIThread(() =>
                {
                    WPFDoEvents.AssertThisCodeIsRunningInTheUIThread();

                    foreach (ExpeditionPaperSuggestions.Result result in results)
                    {
                        PDFDocumentNodeContent content = new PDFDocumentNodeContent(result.pdf_document.Fingerprint, result.pdf_document.LibraryRef.Id);
                        NodeControlAddingByKeyboard.AddChildToNodeControl(node_control, content, false);
                    }
                });
            }
        }
        internal static void AddDocumentsInfluentialInDistribution(NodeControl node_control_, Library library, ExpeditionDataSource eds, float[] tags_distribution)
        {
            Logging.Info("+Performing ThemedPageRank on {0} documents", eds.LDAAnalysis.NUM_DOCS);

            // We have the distribution of the topic in tags_distribution

            // Create an array for the document biases
            // Fill the array using the dot product of the document distribution dotted with the topic distribution - then normalise
            double[] biases = new double[eds.LDAAnalysis.NUM_DOCS];
            for (int doc = 0; doc < eds.LDAAnalysis.NUM_DOCS; ++doc)
            {
                double bias_num_squared = 0;
                double bias_den_doc     = 0;
                double bias_den_tags    = 0;

                for (int topic = 0; topic < eds.LDAAnalysis.NUM_TOPICS; ++topic)
                {
                    bias_num_squared += eds.LDAAnalysis.DensityOfTopicsInDocuments[doc, topic] * tags_distribution[topic];
                    bias_den_doc     += eds.LDAAnalysis.DensityOfTopicsInDocuments[doc, topic] * eds.LDAAnalysis.DensityOfTopicsInDocuments[doc, topic];
                    bias_den_tags    += tags_distribution[topic] * tags_distribution[topic];
                }

                biases[doc] = bias_num_squared / (Math.Sqrt(bias_den_doc) * Math.Sqrt(bias_den_tags));
            }

            // Then build up a matrix FROM each document -
            List <int>[] references_outbound = new List <int> [eds.LDAAnalysis.NUM_DOCS];
            for (int doc = 0; doc < eds.LDAAnalysis.NUM_DOCS; ++doc)
            {
                references_outbound[doc] = new List <int>();

                string      fingerprint  = eds.docs[doc];
                PDFDocument pdf_document = library.GetDocumentByFingerprint(fingerprint);
                if (null == pdf_document)
                {
                    Logging.Warn("ThemeExplorer::AddInInfluential: Cannot find document anymore for fingerprint {0}", fingerprint);
                }
                else
                {
                    List <Citation> citations_outbound = pdf_document.PDFDocumentCitationManager.GetOutboundCitations();
                    foreach (Citation citation in citations_outbound)
                    {
                        string fingerprint_inbound = citation.fingerprint_inbound;
                        if (eds.docs_index.ContainsKey(fingerprint_inbound))
                        {
                            int doc_inbound = eds.docs_index[fingerprint_inbound];
                            references_outbound[doc].Add(doc_inbound);
                        }
                    }
                }
            }

            // Space for the pageranks
            double[] pageranks_current = new double[eds.LDAAnalysis.NUM_DOCS];
            double[] pageranks_next    = new double[eds.LDAAnalysis.NUM_DOCS];

            // Initialise
            for (int doc = 0; doc < eds.LDAAnalysis.NUM_DOCS; ++doc)
            {
                pageranks_current[doc] = biases[doc];
            }

            // Iterate
            int NUM_ITERATIONS = 20;

            for (int iteration = 0; iteration < NUM_ITERATIONS; ++iteration)
            {
                Logging.Info("Performing ThemedPageRank iteration {0}", iteration);

                // Spread out the activation pageranks
                for (int doc = 0; doc < eds.LDAAnalysis.NUM_DOCS; ++doc)
                {
                    foreach (int doc_inbound in references_outbound[doc])
                    {
                        pageranks_next[doc_inbound] += biases[doc] / references_outbound[doc].Count;
                    }
                }

                // Mix the spread out pageranks with the initial bias pageranks
                double ALPHA = 0.5;
                for (int doc = 0; doc < eds.LDAAnalysis.NUM_DOCS; ++doc)
                {
                    pageranks_next[doc] = (1 - ALPHA) * pageranks_next[doc] + ALPHA * biases[doc];
                }

                // Normalise the next pageranks
                double total = 0;
                for (int doc = 0; doc < eds.LDAAnalysis.NUM_DOCS; ++doc)
                {
                    total += pageranks_next[doc];
                }
                if (0 < total)
                {
                    for (int doc = 0; doc < eds.LDAAnalysis.NUM_DOCS; ++doc)
                    {
                        pageranks_next[doc] /= total;
                    }
                }

                // Switch in the next pageranks because we will overwrite them
                double[] pageranks_temp = pageranks_current;
                pageranks_current = pageranks_next;
                pageranks_next    = pageranks_temp;
            }

            // Sort the pageranks, descending
            int[] docs = new int[eds.LDAAnalysis.NUM_DOCS];
            for (int doc = 0; doc < eds.LDAAnalysis.NUM_DOCS; ++doc)
            {
                docs[doc] = doc;
            }
            Array.Sort(pageranks_current, docs);
            Array.Reverse(pageranks_current);
            Array.Reverse(docs);

            // Make the nodes
            for (int doc = 0; doc < 10 && doc < docs.Length; ++doc)
            {
                int    doc_id      = docs[doc];
                string fingerprint = eds.docs[doc_id];

                PDFDocument pdf_document = library.GetDocumentByFingerprint(fingerprint);
                if (null == pdf_document)
                {
                    Logging.Warn("Couldn't find similar document with fingerprint {0}", fingerprint);
                }
                else
                {
                    PDFDocumentNodeContent content = new PDFDocumentNodeContent(pdf_document.Fingerprint, pdf_document.Library.WebLibraryDetail.Id);
                    NodeControlAddingByKeyboard.AddChildToNodeControl(node_control_, content, false);
                }
            }
        }