Exemplo n.º 1
0
        public void Add(ConnectorControl connector_control)
        {
            connector_controls.Add(connector_control);

            links_from_to.Add(connector_control.node_from, connector_control);
            links_from_to.Add(connector_control.node_to, connector_control);
        }
        // -----------------------------

        internal static MultiMapSet <string, string> GetNodeItems(Library library, HashSet <string> parent_fingerprints)
        {
            List <PDFDocument> pdf_documents = null;

            if (null == parent_fingerprints)
            {
                pdf_documents = library.PDFDocuments;
            }
            else
            {
                pdf_documents = library.GetDocumentByFingerprints(parent_fingerprints);
            }

            MultiMapSet <string, string> tags_with_fingerprints = new MultiMapSet <string, string>();

            foreach (PDFDocument pdf_document in pdf_documents)
            {
                // The category of year
                tags_with_fingerprints.Add(GetYearCategory(pdf_document), pdf_document.Fingerprint);

                // The year itself
                string year_combined = pdf_document.YearCombined;
                if (PDFDocument.UNKNOWN_YEAR != year_combined)
                {
                    tags_with_fingerprints.Add(year_combined, pdf_document.Fingerprint);
                }
            }

            return(tags_with_fingerprints);
        }
        // -----------------------------

        internal static MultiMapSet <string, string> GetNodeItems(Library library, HashSet <string> parent_fingerprints)
        {
            Logging.Info("+Getting node items for " + "Tags");

            List <PDFDocument> pdf_documents = null;

            if (null == parent_fingerprints)
            {
                pdf_documents = library.PDFDocuments;
            }
            else
            {
                pdf_documents = library.GetDocumentByFingerprints(parent_fingerprints);
            }

            // Load all the annotations upfront so we dont have to go to the database for each PDF
            Dictionary <string, byte[]> library_items_annotations_cache = library.LibraryDB.GetLibraryItemsAsCache(PDFDocumentFileLocations.ANNOTATIONS);

            // Build up the map of PDFs associated with each tag
            MultiMapSet <string, string> tags_with_fingerprints = new MultiMapSet <string, string>();

            foreach (PDFDocument pdf_document in pdf_documents)
            {
                bool has_tag = false;
                foreach (string tag in TagTools.ConvertTagBundleToTags(pdf_document.Tags))
                {
                    tags_with_fingerprints.Add(tag, pdf_document.Fingerprint);
                    has_tag = true;
                }

                // And check the annotations
                foreach (var pdf_annotation in pdf_document.GetAnnotations(library_items_annotations_cache))
                {
                    if (!pdf_annotation.Deleted)
                    {
                        foreach (string annotation_tag in TagTools.ConvertTagBundleToTags(pdf_annotation.Tags))
                        {
                            tags_with_fingerprints.Add(annotation_tag, pdf_document.Fingerprint);
                            has_tag = true;
                        }
                    }
                }


                if (!has_tag)
                {
                    tags_with_fingerprints.Add(NO_TAG_KEY, pdf_document.Fingerprint);
                }
            }

            Logging.Info("-Getting node items");
            return(tags_with_fingerprints);
        }
Exemplo n.º 4
0
        public void MultiMapSet_duplicates()
        {
            var personnesParVille = new MultiMapSet <string, string>();

            //Lookup<string, string> personnesParVille = (Lookup<string, string>)new List<Person>().ToLookup(k => k.Ville, v => v.Nom);
            personnesParVille.Add("Paris", "Arthur");
            personnesParVille.Add("Paris", "Arthur");
            personnesParVille.Add("Paris", "Laurent");
            personnesParVille.Add("Paris", "David");
            personnesParVille.Add("Versailles", "Arthur");
            Check.That(personnesParVille.Count).IsEqualTo(2);
            Check.That(personnesParVille["Paris"].Count).IsEqualTo(3);
            Check.That(personnesParVille["Versailles"].Count).IsEqualTo(1);

            personnesParVille.Add("Versailles", "Arthur");
            Check.That(personnesParVille["Versailles"].Count).IsEqualTo(1);
            Check.That(personnesParVille.Count).IsEqualTo(2);

            personnesParVille.Add("Versailles", "Annabelle");
            Check.That(personnesParVille["Versailles"].Count).IsEqualTo(2);
            Check.That(personnesParVille.Count).IsEqualTo(2);

            personnesParVille.Add("Aix", "Françoise");
            Check.That(personnesParVille.Count).IsEqualTo(3);
            Check.That(personnesParVille["Aix"].Count).IsEqualTo(1);
        }
Exemplo n.º 5
0
        // -----------------------------

        internal static MultiMapSet <string, string> GetNodeItems(Library library, HashSet <string> parent_fingerprints)
        {
            List <PDFDocument> pdf_documents = null;

            if (null == parent_fingerprints)
            {
                pdf_documents = library.PDFDocuments;
            }
            else
            {
                pdf_documents = library.GetDocumentByFingerprints(parent_fingerprints);
            }

            MultiMapSet <string, string> tags_with_fingerprints = new MultiMapSet <string, string>();

            foreach (PDFDocument pdf_document in pdf_documents)
            {
                string type = null;
                if (null != pdf_document.BibTexItem)
                {
                    type = pdf_document.BibTexItem.Type;
                }

                tags_with_fingerprints.Add(type ?? "(none)", pdf_document.Fingerprint);
            }

            return(tags_with_fingerprints);
        }
Exemplo n.º 6
0
        // -----------------------------

        internal static MultiMapSet <string, string> GetNodeItems(Library library, HashSet <string> parent_fingerprints)
        {
            Logging.Info("+Getting node items for " + "Authors");

            List <PDFDocument> pdf_documents = null;

            if (null == parent_fingerprints)
            {
                pdf_documents = library.PDFDocuments;
            }
            else
            {
                pdf_documents = library.GetDocumentByFingerprints(parent_fingerprints);
            }

            MultiMapSet <string, string> tags_with_fingerprints = new MultiMapSet <string, string>();

            foreach (PDFDocument pdf_document in pdf_documents)
            {
                List <NameTools.Name> names = SimilarAuthors.GetAuthorsForPDFDocument(pdf_document);
                foreach (NameTools.Name name in names)
                {
                    tags_with_fingerprints.Add(name.last_name, pdf_document.Fingerprint);
                }
            }

            Logging.Info("-Getting node items");
            return(tags_with_fingerprints);
        }
        private static MultiMapSet <string, string> GenerateMap_None(Library library, HashSet <string> parent_fingerprints)
        {
            List <PDFDocument> pdf_documents = null;

            if (null == parent_fingerprints)
            {
                pdf_documents = library.PDFDocuments;
            }
            else
            {
                pdf_documents = library.GetDocumentByFingerprints(parent_fingerprints);
            }

            MultiMapSet <string, string> tags_with_fingerprints = new MultiMapSet <string, string>();

            foreach (PDFDocument pdf_document in pdf_documents)
            {
                tags_with_fingerprints.Add("All", pdf_document.Fingerprint);
            }
            return(tags_with_fingerprints);
        }
        private static MultiMapSet <string, string> GenerateMap_None(Library library, HashSet <string> parent_fingerprints)
        {
            List <PDFDocument> pdf_documents = null;

            if (null == parent_fingerprints)
            {
                pdf_documents = library.PDFDocuments;
            }
            else
            {
                pdf_documents = library.GetDocumentByFingerprints(parent_fingerprints);
            }
            Logging.Debug特("LibraryPivotExplorerControl: processing {0} documents from library {1}", pdf_documents.Count, library.WebLibraryDetail.Title);

            MultiMapSet <string, string> tags_with_fingerprints = new MultiMapSet <string, string>();

            foreach (PDFDocument pdf_document in pdf_documents)
            {
                tags_with_fingerprints.Add("All", pdf_document.Fingerprint);
            }
            return(tags_with_fingerprints);
        }
        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);
        }
Exemplo n.º 10
0
        public MultiMapSet <string, string> GetTagsWithDocuments(HashSet <string> documents)
        {
            HashSet <string> relevant_tags = new HashSet <string>();

            foreach (string document in documents)
            {
                relevant_tags.UnionWith(ai_documents_with_tags.Get(document));
            }

            MultiMapSet <string, string> results = new MultiMapSet <string, string>();

            foreach (string relevant_tag in relevant_tags)
            {
                foreach (string relevant_document in ai_tags_with_documents.Get(relevant_tag))
                {
                    if (documents.Contains(relevant_document))
                    {
                        results.Add(relevant_tag, relevant_document);
                    }
                }
            }

            return(results);
        }
Exemplo n.º 11
0
        private static MultiMapSet <string, string> GenerateMap_None(WebLibraryDetail web_library_detail, HashSet <string> parent_fingerprints)
        {
            WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread();

            List <PDFDocument> pdf_documents = null;

            if (null == parent_fingerprints)
            {
                pdf_documents = web_library_detail.Xlibrary.PDFDocuments;
            }
            else
            {
                pdf_documents = web_library_detail.Xlibrary.GetDocumentByFingerprints(parent_fingerprints);
            }
            Logging.Debug特("LibraryPivotExplorerControl: processing {0} documents from library {1}", pdf_documents.Count, web_library_detail.Title);

            MultiMapSet <string, string> tags_with_fingerprints = new MultiMapSet <string, string>();

            foreach (PDFDocument pdf_document in pdf_documents)
            {
                tags_with_fingerprints.Add("All", pdf_document.Fingerprint);
            }
            return(tags_with_fingerprints);
        }
Exemplo n.º 12
0
 public void Associate(string tag, string document_fingerprint)
 {
     ai_tags_with_documents.Add(tag, document_fingerprint);
     ai_documents_with_tags.Add(document_fingerprint, tag);
 }
Exemplo n.º 13
0
        public MultiMapSet <string, string> Check()
        {
            MultiMapSet <string, string> dict = new MultiMapSet <string, string>();

            foreach (ComponentQueue queue in this.dictionary.Values)
            {
                foreach (Entity entity in queue.Queue)
                {
                    Type type = entity.GetType();

#if SERVER
                    if (type.IsSubclassOf(typeof(LogDefine)))
                    {
                        continue;
                    }
#endif

                    FieldInfo[] fieldInfos = type.GetFields();
                    foreach (FieldInfo fieldInfo in fieldInfos)
                    {
                        if (fieldInfo.IsLiteral)
                        {
                            continue;
                        }

                        if (fieldInfo.GetCustomAttributes(typeof(NoMemoryCheck)).Count() > 0)
                        {
                            continue;
                        }

                        Type fieldType = fieldInfo.FieldType;
                        if (fieldType == typeof(int))
                        {
                            if ((int)fieldInfo.GetValue(entity) != 0)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (fieldType == typeof(uint))
                        {
                            if ((uint)fieldInfo.GetValue(entity) != 0)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (fieldType == typeof(long))
                        {
                            if ((long)fieldInfo.GetValue(entity) != 0)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (fieldType == typeof(ulong))
                        {
                            if ((ulong)fieldInfo.GetValue(entity) != 0)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (fieldType == typeof(short))
                        {
                            if ((short)fieldInfo.GetValue(entity) != 0)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (fieldType == typeof(ushort))
                        {
                            if ((ushort)fieldInfo.GetValue(entity) != 0)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (fieldType == typeof(float))
                        {
                            if (Math.Abs((float)fieldInfo.GetValue(entity)) > 0.0001)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (fieldType == typeof(double))
                        {
                            if (Math.Abs((double)fieldInfo.GetValue(entity)) > 0.0001)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (fieldType == typeof(bool))
                        {
                            if ((bool)fieldInfo.GetValue(entity) != false)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (typeof(ICollection).IsAssignableFrom(fieldType))
                        {
                            object fieldValue = fieldInfo.GetValue(entity);
                            if (fieldValue == null)
                            {
                                continue;
                            }
                            if (((ICollection)fieldValue).Count != 0)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        PropertyInfo propertyInfo = fieldType.GetProperty("Count");
                        if (propertyInfo != null)
                        {
                            if ((int)propertyInfo.GetValue(fieldInfo.GetValue(entity)) != 0)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }

                        if (fieldType.IsClass)
                        {
                            if (fieldInfo.GetValue(entity) != null)
                            {
                                dict.Add(type.Name, fieldInfo.Name);
                            }
                            continue;
                        }
                    }
                }
            }

            return(dict);
        }