private void DrawWord(AggregateData aggregate, int _maxCount) { double ratio = (double)aggregate.Count / (double)_maxCount; Console.WriteLine("ratio:" + ratio); int size = (int)Math.Round(250 * ratio); bool b = true; while (b) { int x = rnd.Next(0, width - 80); int y = rnd.Next(0, height - 50); demoG.DrawString(aggregate.Word, new Font(font, size), Brushes.Blue, x, y); Console.WriteLine("demo:" + aggregate.Word); if (CheckMeasureSize(aggregate.Word, new Font(font, size), x, y)) { g.DrawString(aggregate.Word, new Font(font, size), Brushes.Blue, x, y); SetMeasureSize(aggregate.Word, new Font(font, size), x, y); b = false; } } }
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); }