示例#1
0
        /// <summary>
        /// Builds the table.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public DataTable BuildTable(cloudMatrixSettings settings, cloudMatrixDataTableType type)
        {
            DataTable table = new DataTable();

            table.SetTitle("CloudMatrix_" + name);
            table.SetDescription(description.or("Semantic cloud matrix report"));

            List <lemmaSemanticCloud> clouds = this.Get1stKeys().ToList();

            Int32 ci = 0;

            foreach (lemmaSemanticCloud cl in clouds)
            {
                table.SetAdditionalInfoEntry("Cloud " + ci, cl.className);
                if (cl.className.isNullOrEmpty())
                {
                    cl.className = "C" + ci.ToString("D2");
                }
                if (cl.name.isNullOrEmpty())
                {
                    cl.name = cl.className;
                }
                ci++;
            }

            instanceCountCollection <String> counter = GetCounter(type.HasFlag(cloudMatrixDataTableType.initialState));

            String format = "F5";

            if (type.HasFlag(cloudMatrixDataTableType.normalizedValues))
            {
                format = "F5";
            }
            else
            {
                format = "";
            }

            table.Add("Class", "Name of DocumentSetClass attached to the semantic clouds", "", typeof(String), imbSCI.Core.enums.dataPointImportance.normal);

            for (int i = 0; i < clouds.Count; i++)
            {
                table.Add(clouds[i].className, clouds[i].description, "C_" + i.ToString(), typeof(Double), imbSCI.Core.enums.dataPointImportance.normal, format, clouds[i].className);
            }

            table.Add("LemmasInitial", "Number of lemmas in the cloud, before reduction", "", typeof(Int32), imbSCI.Core.enums.dataPointImportance.important, "", "Lemmas - initial");

            table.Add("LinkRateInitial", "Link per node ratio, initial state", "", typeof(Double), imbSCI.Core.enums.dataPointImportance.normal, "F3", "Link rate initial");
            table.Add("LemmasAfter", "Number of lemmas in the cloud, after reduction", "", typeof(Int32), imbSCI.Core.enums.dataPointImportance.important, "", "Lemmas - after");

            table.Add("LinkRateAfter", "Link per node ratio, after reduction", "", typeof(Int32), imbSCI.Core.enums.dataPointImportance.normal, "F3", "Link rate after");

            for (int y = 0; y < clouds.Count; y++)
            {
                DataRow dr = table.NewRow();

                dr["Class"] = clouds[y].className;

                for (int x = 0; x < clouds.Count; x++)
                {
                    if (y == x)
                    {
                        dr[clouds[x].className] = 0;
                    }
                    else
                    {
                        dr[clouds[x].className] = GetCellNumber(clouds[x], clouds[y], type, counter);
                    }
                }

                dr["LemmasInitial"] = numberOfLemmas[clouds[y]];
                dr["LemmasAfter"]   = clouds[y].CountNodes();

                dr["LinkRateInitial"] = numberOfLinks[clouds[y]].GetRatio(numberOfLemmas[clouds[y]]);
                dr["LinkRateAfter"]   = clouds[y].CountLinks().GetRatio(clouds[y].CountNodes());

                table.Rows.Add(dr);
            }

            if (type.HasFlag(cloudMatrixDataTableType.overlapValue))
            {
                DataRow dr = table.NewRow();

                dr["Class"] = "Weight sums";

                for (int y = 0; y < clouds.Count; y++)
                {
                    Double sum = 0;
                    for (int x = 0; x < clouds.Count; x++)
                    {
                        sum += this[clouds[x], clouds[y]].Sum(c => c.weight);  // GetCellNumber(clouds[x], clouds[y], type, counter);
                    }
                    dr[clouds[y].className] = sum;
                    //dr[clouds[x].name] = clouds[x].nodes.Sum(s => s.weight);
                }

                dr["LemmasInitial"] = 0;
                dr["LemmasAfter"]   = 0;

                dr["LinkRateInitial"] = 0;
                dr["LinkRateAfter"]   = 0;

                table.Rows.Add(dr);
            }

            var ty = type.getEnumListFromFlags <cloudMatrixDataTableType>();

            foreach (cloudMatrixDataTableType t in ty)
            {
                table.SetAdditionalInfoEntry(t.toStringSafe(), t.toStringSafe().imbTitleCamelOperation(true));
            }

            if (type.HasFlag(cloudMatrixDataTableType.initialState))
            {
                table.AddExtra("The table shows the state of the matrix before transformation (filtration).");
            }
            else
            {
                table.AddExtra("The table shows the state of the matrix after transformation (filtration).");
            }

            if (type.HasFlag(cloudMatrixDataTableType.overlapSize))
            {
                table.AddExtra("Values in the table are showing number of lemmas that are common to the clouds (of x and y axis).");
            }
            else if (type.HasFlag(cloudMatrixDataTableType.maxCloudFrequency))
            {
                table.AddExtra("Values in the table are showing highest Cloud Frequency for a term (at x and y axis).");
            }
            else if (type.HasFlag(cloudMatrixDataTableType.minCloudFrequency))
            {
                table.AddExtra("Values in the table are showing lowest Cloud Frequency for a term (at x and y axis).");
            }
            else if (type.HasFlag(cloudMatrixDataTableType.overlapValue))
            {
                table.AddExtra("Values in the table are showing sum of local weights for overlapping terms. The last row contains sum of weights for the class cloud.");
            }

            if (type.HasFlag(cloudMatrixDataTableType.normalizedValues))
            {
                if (type.HasFlag(cloudMatrixDataTableType.overlapSize))
                {
                    table.AddExtra("The values are normalized to 0-1, where 1 is overlap size in initial state for each x,y cell.");
                }
                else
                {
                    table.AddExtra("The values are normalized to 0-1.");
                }
            }
            else
            {
                table.AddExtra("The values are absolute.");
            }


            table.SetAdditionalInfoEntry("Max. CF", MaxCloudFrequency);
            table.SetAdditionalInfoEntry("Min. CF", MinCloudFrequency);
            table.SetAdditionalInfoEntry("Max. Overlap", MaxOverlap);
            table.SetAdditionalInfoEntry("Min. Overlap", MinOverlap);
            return(table);
        }
示例#2
0
        /// <summary>
        /// Gets the value for cell targeted
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <param name="type">The type.</param>
        /// <param name="counter">The counter.</param>
        /// <returns></returns>
        public Double GetCellNumber(lemmaSemanticCloud x, lemmaSemanticCloud y, cloudMatrixDataTableType type, instanceCountCollection <String> counter)
        {
            Double output = 0;

            List <freeGraphNodeBase> selected = this[x, y];

            Double min = MaxCloudFrequency;
            Double max = MinCloudFrequency;



            if (type.HasFlag(cloudMatrixDataTableType.overlapValue))
            {
                if (type.HasFlag(cloudMatrixDataTableType.initialState))
                {
                    output = selected.Sum(s => s.weight);
                }
                else
                {
                    output = x.GetOverlap(y).Sum(s => s.weight);
                }
            }

            if (output == 0)
            {
                if (type.HasFlag(cloudMatrixDataTableType.normalizedValues))
                {
                    if (type.HasFlag(cloudMatrixDataTableType.overlapSize))
                    {
                        if (type.HasFlag(cloudMatrixDataTableType.initialState))
                        {
                            output = selected.Count.GetRatio(MaxOverlap);
                        }
                        else
                        {
                            if (x == y)
                            {
                                output = 0;
                            }
                            else
                            {
                                output = x.GetOverlap(y).Count.GetRatio(selected.Count);
                            }
                        }
                    }
                    else if (type.HasFlag(cloudMatrixDataTableType.maxCloudFrequency) || type.HasFlag(cloudMatrixDataTableType.minCloudFrequency))
                    {
                        for (int i = 0; i < selected.Count; i++)
                        {
                            freeGraphNodeBase ne = selected[i];
                            min = Math.Min(min, (Double)counter[ne.name]);
                            max = Math.Max(max, (Double)counter[ne.name]);
                        }

                        if (type.HasFlag(cloudMatrixDataTableType.maxCloudFrequency))
                        {
                            output = max.GetRatio(MaxCloudFrequency);
                        }
                        else
                        {
                            output = min.GetRatio(MinCloudFrequency);
                        }
                    }
                }
                else
                {
                    if (type.HasFlag(cloudMatrixDataTableType.overlapSize))
                    {
                        if (type.HasFlag(cloudMatrixDataTableType.initialState))
                        {
                            output = selected.Count;
                        }
                        else
                        {
                            if (x == y)
                            {
                                output = 0;
                            }
                            else
                            {
                                output = x.GetOverlap(y).Count;
                            }
                        }
                    }
                    else if (type.HasFlag(cloudMatrixDataTableType.maxCloudFrequency) || type.HasFlag(cloudMatrixDataTableType.minCloudFrequency))
                    {
                        for (int i = 0; i < selected.Count; i++)
                        {
                            freeGraphNodeBase ne = selected[i];
                            min = Math.Min(min, (Double)counter[ne.name]);
                            max = Math.Max(max, (Double)counter[ne.name]);
                        }

                        if (type.HasFlag(cloudMatrixDataTableType.maxCloudFrequency))
                        {
                            output = max;
                        }
                        else
                        {
                            output = min;
                        }
                    }
                }
            }

            return(output);
        }