/// <summary>
        /// Returns common finger print
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns></returns>
        public static StructureFingerPrint CommonFingerPrint(IEnumerable <StructureFingerPrint> input)
        {
            StructureFingerPrint output = new StructureFingerPrint();

            frequencyCounter <String> XPathFrequencyCounter = new frequencyCounter <string>();

            Int32 c = 0;

            foreach (StructureFingerPrint print in input)
            {
                foreach (String xpath in print.XPathList)
                {
                    XPathFrequencyCounter.Count(xpath);
                }
                c++;
            }

            var bins = XPathFrequencyCounter.GetFrequencyBins();

            if (bins.ContainsKey(c))
            {
                foreach (String xpath in bins[c])
                {
                    output.XPathList.Add(xpath);
                }
            }
            else
            {
                return(null);
            }

            return(output);
        }
Exemplo n.º 2
0
        public DirectedGraphWithSourceData Publish(folderNode folder, String name)
        {
            TagCounter     = new frequencyCounter <string>();
            NodeTagCounter = new frequencyCounter <string>();
            RebuildIndex();


            String listPath       = folder.pathFor("nd_" + name + "_list.txt", imbSCI.Data.enums.getWritableFileMode.overwrite, "List of selected nodes");
            String statPath       = folder.pathFor("nd_" + name + "_stats.txt", imbSCI.Data.enums.getWritableFileMode.overwrite, "Stats of selected nodes");
            String graphPath      = folder.pathFor("nd_" + name + "_graph.dgml", imbSCI.Data.enums.getWritableFileMode.overwrite, "Structure graph");
            String graphStatsPath = folder.pathFor("nd_" + name + "_graph_stats.txt", imbSCI.Data.enums.getWritableFileMode.overwrite, "Stats of the complete graph");

            StringBuilder listBuilder      = new StringBuilder();
            StringBuilder statBuilder      = new StringBuilder();
            StringBuilder graphStatBuilder = new StringBuilder();

            foreach (var item in items)
            {
                listBuilder.AppendLine(item.XPath);
                TagCounter.Count(item.node.Name);
            }


            var freqBins = TagCounter.GetFrequencyBins();

            foreach (var bin in freqBins)
            {
                statBuilder.AppendLine(bin.Key + " " + bin.Value.toCsvInLine());
            }



            var GraphFreqBins = NodeTagCounter.GetFrequencyBins();

            foreach (var bin in GraphFreqBins)
            {
                graphStatBuilder.AppendLine(bin.Key + " " + bin.Value.toCsvInLine());
            }

            DirectedGraphWithSourceData dgml = BuildDGML();

            dgml.Save(graphPath, imbSCI.Data.enums.getWritableFileMode.overwrite);

            File.WriteAllText(listPath, listBuilder.ToString());
            File.WriteAllText(statPath, statBuilder.ToString());
            File.WriteAllText(graphStatsPath, graphStatBuilder.ToString());

            return(dgml);
        }