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

            foreach (var log in logs.Where(log => log.Tags != null))
            {
                tags_count += log.Tags.Length;
                foreach (var tag in log.Tags)
                {
                    if (tags_map.ContainsKey(HitomiCommon.LegalizeTag(tag)))
                    {
                        tags_map[HitomiCommon.LegalizeTag(tag)] += 1;
                    }
                    else
                    {
                        tags_map.Add(HitomiCommon.LegalizeTag(tag), 1);
                    }
                }
            }

            foreach (var pair in tags_map)
            {
                rate.Add(pair.Key, pair.Value * pair.Value / (float)tags_count);
            }
        }
Example #2
0
        private void PicDetailElement_Load(object sender, EventArgs e)
        {
            lTitle.Text     = ha.Title;
            lArtist.Text    = string.Join(",", ha.Artists ?? Enumerable.Empty <string>());
            lSeries.Text    = string.Join(",", ha.Series ?? Enumerable.Empty <string>());
            lGroup.Text     = string.Join(",", ha.Groups ?? Enumerable.Empty <string>());
            lCharacter.Text = string.Join(",", ha.Characters ?? Enumerable.Empty <string>());
            lDate.Text      = HitomiDate.estimate_datetime(Convert.ToInt32(ha.Magic)).ToString();
            if (ha.Tags != null)
            {
                ha.Tags.ToList().ForEach((a) =>
                {
                    a = HitomiCommon.LegalizeTag(a);
                    if (a.StartsWith("female:"))
                    {
                        AddTagToPanel(a.Substring("female:".Length), 1);
                    }
                    else if (a.StartsWith("male:"))
                    {
                        AddTagToPanel(a.Substring("male:".Length), 2);
                    }
                    else
                    {
                        AddTagToPanel(a, 0);
                    }
                });
            }
            if (HitomiSetting.Instance.GetModel().UsingExHentaiBaseOpener)
            {
                metroButton4.Text = "익헨에서 열기";
            }
            lLang.Text = ha.Language;
            if (HitomiSetting.Instance.GetModel().Language != "ALL")
            {
                label9.Dispose();
                lLang.Dispose();
            }

            for (int i = 0; i < Controls.Count; i++)
            {
                if (Controls[i] is Label && Controls[i] != lPage)
                {
                    ConvertToVUILabel(Controls[i--] as Label);
                }
            }

            if (HitomiSetting.Instance.GetModel().ShowPageCount)
            {
                Task.Run(() => {
                    string ppp = HitomiCore.GetPageCount(this).ToString() + "p";
                    this.Send(() => lPage.Text = ppp);
                });
            }
            else
            {
                lPage.Dispose();
            }
        }
Example #3
0
        private void frmGalleryInfo_LoadAsync(object sender, EventArgs e)
        {
            if (pic != null)
            {
                pbImage.Image   = pic.Image;
                lTitle.Text     = pic.Article.Title;
                lArtist.Text    = string.Join(",", pic.Article.Artists ?? Enumerable.Empty <string>());
                lSeries.Text    = string.Join(",", pic.Article.Series ?? Enumerable.Empty <string>());
                lGroup.Text     = string.Join(",", pic.Article.Groups ?? Enumerable.Empty <string>());
                lCharacter.Text = string.Join(",", pic.Article.Characters ?? Enumerable.Empty <string>());
                textBox1.Text   = string.Join(",", pic.Article.Tags ?? Enumerable.Empty <string>());

                pic.Article.Tags.ToList().ForEach((a) =>
                {
                    a = HitomiCommon.LegalizeTag(a);
                    if (a.StartsWith("female:"))
                    {
                        AddTagToPanel(a.Substring("female:".Length), 1);
                    }
                    else if (a.StartsWith("male:"))
                    {
                        AddTagToPanel(a.Substring("male:".Length), 2);
                    }
                    else
                    {
                        AddTagToPanel(a, 0);
                    }
                });
            }
            else
            {
                lTitle.Text     = metadata.Name;
                lArtist.Text    = string.Join(",", metadata.Artists ?? Enumerable.Empty <string>());
                lSeries.Text    = string.Join(",", metadata.Parodies ?? Enumerable.Empty <string>());
                lGroup.Text     = string.Join(",", metadata.Groups ?? Enumerable.Empty <string>());
                lCharacter.Text = string.Join(",", metadata.Characters ?? Enumerable.Empty <string>());

                metadata.Tags.ToList().ForEach((a) =>
                {
                    if (a.StartsWith("female:"))
                    {
                        AddTagToPanel(a.Substring("female:".Length), 1);
                    }
                    else if (a.StartsWith("male:"))
                    {
                        AddTagToPanel(a.Substring("male:".Length), 2);
                    }
                    else
                    {
                        AddTagToPanel(a, 0);
                    }
                });

                Task.Run(() => download_image());
            }
        }
        public HitomiAnalysisGallery()
        {
            Dictionary <string, int> tag_rank = new Dictionary <string, int>();

            foreach (var v in HitomiLog.Instance.GetEnumerator())
            {
                if (v.Tags == null)
                {
                    continue;
                }
                foreach (var tag in v.Tags)
                {
                    string legalize = HitomiCommon.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)
                {
                    foreach (var tag in metadata.Tags)
                    {
                        if (tag_rank.ContainsKey(tag))
                        {
                            score += 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));
        }
Example #5
0
        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 (HitomiSetting.Instance.GetModel().UsingOnlyFMTagsOnAnalysis&&
                        !tag.StartsWith("female:") && !tag.StartsWith("male:"))
                    {
                        continue;
                    }
                    tags_count += 1;
                    if (tags_map.ContainsKey(HitomiCommon.LegalizeTag(tag)))
                    {
                        tags_map[HitomiCommon.LegalizeTag(tag)] += 1;
                    }
                    else
                    {
                        tags_map.Add(HitomiCommon.LegalizeTag(tag), 1);
                    }
                }
            }

            foreach (var pair in tags_map)
            {
                if (!HitomiSetting.Instance.GetModel().UsingCosineAnalysis)
                {
                    if (!HitomiSetting.Instance.GetModel().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);
                }
            }
        }
Example #6
0
        private void frmGalleryInfo_LoadAsync(object sender, EventArgs e)
        {
            lDate.Text = HitomiDate.estimate_datetime(Convert.ToInt32(id)).ToString();
            if (pic != null)
            {
                pbImage.Image   = pic.Image;
                lTitle.Text     = pic.Article.Title;
                lArtist.Text    = string.Join(",", pic.Article.Artists ?? Enumerable.Empty <string>());
                lSeries.Text    = string.Join(",", pic.Article.Series ?? Enumerable.Empty <string>());
                lGroup.Text     = string.Join(",", pic.Article.Groups ?? Enumerable.Empty <string>());
                lCharacter.Text = string.Join(",", pic.Article.Characters ?? Enumerable.Empty <string>());
                textBox1.Text   = string.Join(",", pic.Article.Tags ?? Enumerable.Empty <string>());

                if (pic.Article.Tags != null)
                {
                    pic.Article.Tags.ToList().ForEach((a) =>
                    {
                        a = HitomiCommon.LegalizeTag(a);
                        if (a.StartsWith("female:"))
                        {
                            AddTagToPanel(a.Substring("female:".Length), 1);
                        }
                        else if (a.StartsWith("male:"))
                        {
                            AddTagToPanel(a.Substring("male:".Length), 2);
                        }
                        else
                        {
                            AddTagToPanel(a, 0);
                        }
                    });
                }
            }
            else
            {
                lTitle.Text     = metadata.Name;
                lArtist.Text    = string.Join(",", metadata.Artists ?? Enumerable.Empty <string>());
                lSeries.Text    = string.Join(",", metadata.Parodies ?? Enumerable.Empty <string>());
                lGroup.Text     = string.Join(",", metadata.Groups ?? Enumerable.Empty <string>());
                lCharacter.Text = string.Join(",", metadata.Characters ?? Enumerable.Empty <string>());

                if (metadata.Tags != null)
                {
                    metadata.Tags.ToList().ForEach((a) =>
                    {
                        if (a.StartsWith("female:"))
                        {
                            AddTagToPanel(a.Substring("female:".Length), 1);
                        }
                        else if (a.StartsWith("male:"))
                        {
                            AddTagToPanel(a.Substring("male:".Length), 2);
                        }
                        else
                        {
                            AddTagToPanel(a, 0);
                        }
                    });
                }

                Task.Run(() => download_image());
            }

            if (HitomiSetting.Instance.GetModel().ShowPageCount)
            {
                Task.Run(() => {
                    string ppp = HitomiCore.GetPageCount(id).ToString() + "p";
                    this.Send(() => lPage.Text = ppp);
                });
            }
            else
            {
                lPage.Dispose();
            }
        }
Example #7
0
        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 HitomiCommon.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));
        }
Example #8
0
        private void CustomArtistRecommendation_Load(object sender, EventArgs e)
        {
            ColumnSorter.InitListView(lvCustomTag);
            ColumnSorter.InitListView(lvArtists);

            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 (HitomiSetting.Instance.GetModel().UsingOnlyFMTagsOnAnalysis&&
                            !tag.StartsWith("female:") && !tag.StartsWith("male:"))
                        {
                            continue;
                        }
                        if (tags_map.ContainsKey(HitomiCommon.LegalizeTag(tag)))
                        {
                            tags_map[HitomiCommon.LegalizeTag(tag)] += 1;
                        }
                        else
                        {
                            tags_map.Add(HitomiCommon.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));

            List <ListViewItem> lvil = new List <ListViewItem>();

            foreach (var item in list)
            {
                lvil.Add(new ListViewItem(new string[] { item.Key, item.Value.ToString() }));
            }
            lvCustomTag.Items.Clear();
            lvCustomTag.Items.AddRange(lvil.ToArray());

            lvil.Clear();
            var list2 = HitomiAnalysis.Instance.Rank.ToList();

            for (int i = 0; i < list2.Count; i++)
            {
                lvil.Add(new ListViewItem(new string[] {
                    (i + 1).ToString(),
                    list2[i].Item1,
                    HitomiAnalysis.Instance.ArtistCount[list2[i].Item1].ToString(),
                    list2[i].Item2.ToString(),
                    list2[i].Item3
                }));
            }
            lvArtists.Items.Clear();
            lvArtists.Items.AddRange(lvil.ToArray());
        }
        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 HitomiCommon.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));
        }