コード例 #1
0
        public void startInference(UDCTree UDCHierarchy, int depth = 0)
        {
            SubtypeMiner miner        = null;
            var          typesAtDepth = UDCHierarchy.GetAllTypesAtDepth(depth);

            foreach (var v in typesAtDepth)
            {
                UDCTree subTree = new UDCTree(v);
                Console.WriteLine("Running Inference for {0} ...", v.Value.MetadataName);
                var typeNamesOfDescendants = UDCHierarchy.GetTypeNamesOfDescendants(v);
                miner = new SubtypeMiner(new HashSet <string>(typeNamesOfDescendants), _typeRelations, 50);
                SubTreeResults res = new SubTreeResults(subTree, miner);
                MiningResults.Add(res);

                if (miner.NumRelationships == 0)
                {
                    continue;
                }
                res.computeScores();
                try
                {
                    _typeRelations.ToDot("results/" + v.Value.ToDisplayString() + ".dot", _pathProcessor, res.clusteringResult);
                    writeResultsToDisk(_pathProcessor, res, ResultsDirectory + v.Value.ToDisplayString() + "_result.txt");
                }
                catch (Exception e)
                {
                    Console.WriteLine("{0}", e.Message);
                    continue;
                }
            }
        }
コード例 #2
0
        public void startTypeSpecificNameFlowInference(UDCTree UDCHierarchy, int depth = 0)
        {
            var          typeLocationDict = UDCHierarchy.getUDTLineSpans();
            SubtypeMiner miner            = null;
            var          typesAtDepth     = UDCHierarchy.GetAllTypesAtDepth(depth);

            foreach (var v in UDCHierarchy.getAllTypes())
            {
                if (v.Value.Locations.Length == 0 || !v.Value.Locations.All(x => x.IsInSource))
                {
                    continue;
                }
                UDCTree subTree = new UDCTree(v);
                Console.WriteLine("Running Inference for {0} ...", v.Value.MetadataName);
                miner = new SubtypeMiner(null, _typeRelations, 50, true, v.Value);
                SubTreeResults res = new SubTreeResults(subTree, miner);

                try {
                    MiningResults.Add(res);
                    if (miner.NumRelationships == 0)
                    {
                        continue;
                    }
                    res.computeScores();
                }
                catch (Exception e)
                {
                    Console.WriteLine("{0}", e.Message);
                    continue;
                }
                try
                {
                    //_typeRelations.ToDot(ResultsDirectory + v.Value.ToDisplayString() + ".dot", _pathProcessor, res.clusteringResult);
                    writeResultsToDisk(_pathProcessor, res, ResultsDirectory + v.Value.ToDisplayString() + "_result.txt", miner.GetLineSpanOfType(v.Value));
                }
                catch (Exception e)
                {
                    Console.WriteLine("{0}", e.Message);
                    continue;
                }
            }
        }
コード例 #3
0
        public void startConsolidatedInference(UDCTree UDCHierarchy, int depth = 0)
        {
            SubtypeMiner  miner        = null;
            List <string> alltypes     = new List <string>();
            var           typesAtDepth = UDCHierarchy.GetAllTypesAtDepth(depth);

            foreach (var v in typesAtDepth)
            {
                List <string> typeNamesOfDescendants = new List <string>();
                Console.WriteLine("Running Inference for {0} ...", v.Value.MetadataName);
                try{
                    typeNamesOfDescendants = UDCHierarchy.GetTypeNamesOfDescendants(v);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                alltypes = alltypes.Concat(typeNamesOfDescendants).ToList();
            }

            alltypes = randomUniformSample(alltypes);
            UDCTree subTree = new UDCTree(typesAtDepth.First());

            miner = new SubtypeMiner(new HashSet <string>(alltypes), _typeRelations, 50);
            SubTreeResults res = new SubTreeResults(subTree, miner);

            MiningResults.Add(res);

            if (miner.NumRelationships > 0)
            {
                res.computeScores();
                try
                {
                    //_typeRelations.ToDot(ResultsDirectory + "consolidated.dot", _pathProcessor, res.clusteringResult);
                    writeResultsToDisk(_pathProcessor, res, ResultsDirectory + "consolidated" + "_result.txt");
                }
                catch (Exception e)
                {
                    Console.WriteLine("{0}", e.Message);
                }
            }
        }