private void addMemberButton_Click(object sender, EventArgs e)
        {
            HighNGCollectionEditDialog hnced = new HighNGCollectionEditDialog();

            hnced.IsRegex     = false;
            hnced.Abone       = AboneType.Name;
            hnced.Word        = String.Empty;
            hnced.Url         = String.Empty;
            hnced.Settime     = DateTime.MinValue;
            hnced.ReleaseTime = TimeSpan.MinValue;
            DialogResult dr = hnced.ShowDialog();

            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                NGWord       n   = hnced.NGData;
                ListViewItem lvi = new ListViewItem(new string[]
                {
                    n.AboneTypes.ToString(),
                    n.Word,
                    n.IsRegex.ToString(),
                    n.Url,
                    n.SetTime.ToString(),
                    n.ReleaseTime.ToString()
                });
                this.listView1.Items.Add(lvi);
            }
        }
        private async void SaveData()
        {
            AboneManagement am  = new AboneManagement();
            List <NGWord>   ngs = new List <NGWord>();

            foreach (ListViewItem i in listView1.Items)
            {
                NGWord    nw;
                bool      isReg = false;
                AboneType type  = (AboneType)Enum.Parse(typeof(AboneType), i.SubItems[0].Text);
                if (i.SubItems[2].Text == "True")
                {
                    isReg = true;
                }
                if (isReg)
                {
                    nw = new NGWord(new Regex(i.SubItems[1].Text, RegexOptions.Compiled),
                                    type, i.SubItems[3].Text,
                                    DateTime.Parse(i.SubItems[4].Text),
                                    TimeSpan.Parse(i.SubItems[5].Text));
                }
                else
                {
                    nw = new NGWord(i.SubItems[1].Text,
                                    type, i.SubItems[3].Text,
                                    DateTime.Parse(i.SubItems[4].Text),
                                    TimeSpan.Parse(i.SubItems[5].Text));
                }
                ngs.Add(nw);
            }
            am.NGCollection = ngs;
            await am.InstSave();
        }
 private void okButton_Click(object sender, EventArgs e)
 {
     NGWord nw;
     if (IsRegex)
     {
         nw = new NGWord(new System.Text.RegularExpressions.Regex(this.Word, System.Text.RegularExpressions.RegexOptions.Compiled), this.Abone, this.Url, this.Settime, this.ReleaseTime);
     }
     else
     {
         nw = new NGWord(this.Word, this.Abone, this.Url, this.Settime, this.ReleaseTime);
     }
     this.NGData = nw;
     this.Close();
 }
        private void listView1_DoubleClick(object sender, EventArgs e)
        {
            if (this.listView1.SelectedItems.Count <= 0)
            {
                return;
            }
            int          count = this.listView1.SelectedItems[0].Index;
            ListViewItem lvi   = this.listView1.SelectedItems[0];
            HighNGCollectionEditDialog hnced = new HighNGCollectionEditDialog();

            hnced.IsRegex     = Boolean.Parse(lvi.SubItems[2].Text);
            hnced.Abone       = (AboneType)Enum.Parse(typeof(AboneType), lvi.SubItems[0].Text);
            hnced.Word        = lvi.SubItems[1].Text;
            hnced.Url         = lvi.SubItems[3].Text;
            hnced.Settime     = DateTime.Parse(lvi.SubItems[4].Text);
            hnced.ReleaseTime = TimeSpan.Parse(lvi.SubItems[5].Text);
            DialogResult dr = hnced.ShowDialog();

            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                NGWord n = hnced.NGData;
                if (n.IsRegex)
                {
                    lvi = new ListViewItem(new string[]
                    {
                        n.AboneTypes.ToString(),
                        n.RegexWord.ToString(),
                        n.IsRegex.ToString(),
                        n.Url,
                        n.SetTime.ToString(),
                        n.ReleaseTime.ToString()
                    });
                }
                else
                {
                    lvi = new ListViewItem(new string[]
                    {
                        n.AboneTypes.ToString(),
                        n.Word,
                        n.IsRegex.ToString(),
                        n.Url,
                        n.SetTime.ToString(),
                        n.ReleaseTime.ToString()
                    });
                }
                this.listView1.Items[count] = lvi;
            }
        }
Exemplo n.º 5
0
        private static void Aggregate(List <string> _nounList)
        {
            List <AggregateData> _list = new List <AggregateData>();

            foreach (string _noun in _nounList)
            {
                string[] strArray = _noun.Split(",");
                foreach (string str in strArray)
                {
                    int  count = 0;
                    bool judge = true;
                    foreach (AggregateData aggregateData in _list)
                    {
                        if (aggregateData.Word == str)
                        {
                            judge = false;
                            break;
                        }
                        count++;
                    }
                    if (judge)
                    {
                        _list.Add(new AggregateData {
                            Word = str, Count = 1
                        });
                    }
                    else
                    {
                        AggregateData _aggregateData = _list[count];
                        _list.RemoveAt(count);
                        _list.Add(new AggregateData {
                            Word = _aggregateData.Word, Count = _aggregateData.Count + 1
                        });
                    }
                }
            }

            NGWord NG = new NGWord();
            List <AggregateData> dataList = new List <AggregateData>();

            for (int i = 0; i < 15; i++)
            {
                int max      = 0;
                int maxIndex = 0;
                int count    = 0;
                foreach (AggregateData _aggregateData in _list)
                {
                    if (max < _aggregateData.Count)
                    {
                        max      = _aggregateData.Count;
                        maxIndex = count;
                    }
                    count++;
                }
                if (NG.CheckNG(_list[maxIndex].Word))
                {
                    i--;
                }
                else
                {
                    Console.WriteLine("名詞:" + _list[maxIndex].Word + " 回数:" + _list[maxIndex].Count);
                    dataList.Add(new AggregateData()
                    {
                        Word = _list[maxIndex].Word, Count = _list[maxIndex].Count
                    });
                }
                _list.RemoveAt(maxIndex);
            }

            WordCloud wordCloud = new WordCloud(400, 200);

            wordCloud.MakeImg(dataList);
        }