Пример #1
0
        private void CustomArtistsRecommendWindow_Loaded(object sender, RoutedEventArgs e)
        {
            if (loaded)
            {
                return;
            }
            loaded = true;

            if (!SearchSpace.Instance.IsMetadataLoaded)
            {
                return;
            }

            Dictionary <string, int> tags_map = new Dictionary <string, int>();

            if (!HitomiAnalysis.Instance.UserDefined)
            {
                foreach (var log in HitomiLog.Instance.GetEnumerator().Where(log => log.Tags != null))
                {
                    foreach (var tag in log.Tags)
                    {
                        if (Settings.Instance.HitomiAnalysis.UsingOnlyFMTagsOnAnalysis &&
                            !tag.StartsWith("female:") && !tag.StartsWith("male:"))
                        {
                            continue;
                        }
                        if (tags_map.ContainsKey(HitomiLegalize.LegalizeTag(tag)))
                        {
                            tags_map[HitomiLegalize.LegalizeTag(tag)] += 1;
                        }
                        else
                        {
                            tags_map.Add(HitomiLegalize.LegalizeTag(tag), 1);
                        }
                    }
                }
            }

            var list = tags_map.ToList();

            if (HitomiAnalysis.Instance.UserDefined)
            {
                list = HitomiAnalysis.Instance.CustomAnalysis.Select(x => new KeyValuePair <string, int>(x.Item1, x.Item2)).ToList();
            }
            list.Sort((a, b) => b.Value.CompareTo(a.Value));
            TagList.DataContext = new ArtistDataGridViewModel(list.Select(x => new ArtistDataGridItemViewModel
            {
                항목  = x.Key,
                카운트 = x.Value
            }));

            UpdateResultList();
        }
        public HitomiAnalysisArtist(IEnumerable <HitomiLogModel> logs)
        {
            Dictionary <string, int> tags_map = new Dictionary <string, int>();

            foreach (var log in logs.Where(log => log.Tags != null))
            {
                foreach (var tag in log.Tags)
                {
                    if (Settings.Instance.HitomiAnalysis.UsingOnlyFMTagsOnAnalysis &&
                        !tag.StartsWith("female:") && !tag.StartsWith("male:"))
                    {
                        continue;
                    }
                    tags_count += 1;
                    if (tags_map.ContainsKey(HitomiLegalize.LegalizeTag(tag)))
                    {
                        tags_map[HitomiLegalize.LegalizeTag(tag)] += 1;
                    }
                    else
                    {
                        tags_map.Add(HitomiLegalize.LegalizeTag(tag), 1);
                    }
                }
            }

            foreach (var pair in tags_map)
            {
                if (!Settings.Instance.HitomiAnalysis.UsingCosineAnalysis)
                {
                    if (!Settings.Instance.HitomiAnalysis.RecommendNMultipleWithLength)
                    {
                        rate.Add(pair.Key, pair.Value * pair.Value / (float)tags_count);
                    }
                    else
                    {
                        rate.Add(pair.Key, pair.Value / (float)tags_count);
                    }
                }
                else
                {
                    rate.Add(pair.Key, pair.Value);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 다운로드된 작품들의 태그 리스트를 보여줍니다.
        /// </summary>
        static void ProcessTagList()
        {
            Dictionary <string, int> tags_map = new Dictionary <string, int>();

            if (!HitomiAnalysis.Instance.UserDefined)
            {
                foreach (var log in HitomiLog.Instance.GetEnumerator().Where(log => log.Tags != null))
                {
                    foreach (var tag in log.Tags)
                    {
                        if (Settings.Instance.HitomiAnalysis.UsingOnlyFMTagsOnAnalysis &&
                            !tag.StartsWith("female:") && !tag.StartsWith("male:"))
                        {
                            continue;
                        }
                        if (tags_map.ContainsKey(HitomiLegalize.LegalizeTag(tag)))
                        {
                            tags_map[HitomiLegalize.LegalizeTag(tag)] += 1;
                        }
                        else
                        {
                            tags_map.Add(HitomiLegalize.LegalizeTag(tag), 1);
                        }
                    }
                }
            }

            var list = tags_map.ToList();

            if (HitomiAnalysis.Instance.UserDefined)
            {
                list = HitomiAnalysis.Instance.CustomAnalysis.Select(x => new KeyValuePair <string, int>(x.Item1, x.Item2)).ToList();
            }
            list.Sort((a, b) => b.Value.CompareTo(a.Value));
            for (int i = 0; i < list.Count; i++)
            {
                Console.Instance.WriteLine($"{(i + 1).ToString().PadLeft(5)}: {list[i].Key} ({list[i].Value})");
            }
        }
Пример #4
0
        public HitomiAnalysisTagCount()
        {
            Dictionary <string, int> dic = new Dictionary <string, int>();

            foreach (var legal in from data in HitomiLog.Instance.GetEnumerator() where data.Tags != null from tag in data.Tags select HitomiLegalize.LegalizeTag(tag))
            {
                if (dic.ContainsKey(legal))
                {
                    dic[legal]++;
                }
                else
                {
                    dic.Add(legal, 1);
                }
            }

            tag_count = dic.ToList();
            tag_count.Sort((a, b) => b.Value.CompareTo(a.Value));
        }
        public HitomiAnalysisGallery()
        {
            Dictionary <string, int> tag_rank = new Dictionary <string, int>();

            foreach (var legalize in from v in HitomiLog.Instance.GetEnumerator() where v.Tags != null from tag in v.Tags select HitomiLegalize.LegalizeTag(tag))
            {
                if (tag_rank.ContainsKey(legalize))
                {
                    tag_rank[legalize] += 1;
                }
                else
                {
                    tag_rank.Add(legalize, 1);
                }
            }

            Dictionary <int, Tuple <double, HitomiMetadata> > datas = new Dictionary <int, Tuple <double, HitomiMetadata> >();
            double total_score    = 0.0;
            int    count_metadata = HitomiData.Instance.metadata_collection.Count;

            foreach (var metadata in HitomiData.Instance.metadata_collection)
            {
                double score = 0.0;
                if (metadata.Tags != null)
                {
                    score  = metadata.Tags.Where(tag => tag_rank.ContainsKey(tag)).Aggregate(score, (current, tag) => current + tag_rank[tag]);
                    score /= metadata.Tags.Length;
                }
                total_score += score;
                datas.Add(metadata.ID, new Tuple <double, HitomiMetadata>(score, metadata));
            }

            gallery_data = datas.ToList();
            gallery_data.Sort((p1, p2) => p2.Value.Item1.CompareTo(p1.Value.Item1));
        }