예제 #1
0
        private HashSet <string> GetKeyVariable(SpecificCount data)
        {
            HashSet <string> KeyVariable = new HashSet <string>();

            var _variable   = new Variable();
            var allVariable = _variable.GetAllVariable;
            var qaPair      = data.QAPair;

            qaPair = qaPair.Replace(Variable.TextSuffix, Variable.NullString);
            qaPair = qaPair.Replace(Variable.RuleSetFileDirectory, Variable.NullString);
            string[] subString = qaPair.Split(new char[] { Variable.SpaceChar }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var str in subString)
            {
                if (allVariable.Contains(Variable.StarString + str + Variable.StarString))
                {
                    KeyVariable.Add(Variable.StarString + str + Variable.StarString);
                }
            }
            return(KeyVariable);
        }
예제 #2
0
        private void FindFP(SpecificCount data, ref Dictionary <string, HashSet <string> > clusteringHistory)
        {
            HashSet <string> temp = new HashSet <string>();

            foreach (var unit in data.EachFile)
            {
                foreach (var triple in unit)
                {
                    temp.Add(triple.Predicate);
                }
            }
            Dictionary <string, HashSet <string> > history = new Dictionary <string, HashSet <string> >();
            var eachFile = data.EachFile;

            foreach (var rule in eachFile)
            {
                for (int i = Variable.VariableZero; i < rule.Count - Variable.VariableSingle; i++)
                {
                    if (history.ContainsKey(rule[i].Predicate))
                    {
                        history[rule[i].Predicate].Add(rule[i + Variable.VariableSingle].Predicate);
                    }
                    else
                    {
                        history[rule[i].Predicate] = new HashSet <string> {
                            rule[i + Variable.VariableSingle].Predicate
                        }
                    }
                }
            }
            ;

            Dictionary <string, string> predicateDic = new Dictionary <string, string>();

            foreach (var record in history)
            {
                if (record.Value.Count == Variable.VariableSingle)
                {
                    predicateDic[record.Key] = record.Value.ToList()[Variable.VariableZero];
                }
            }
            Dictionary <string, HashSet <string> > predicateClustering = new Dictionary <string, HashSet <string> >();

            foreach (var kv in predicateDic)
            {
                if (predicateClustering.ContainsKey(kv.Value))
                {
                    predicateClustering[kv.Value].Add(kv.Key);
                }
                else
                {
                    predicateClustering[kv.Value] = new HashSet <string> {
                        kv.Key
                    }
                }
            }
            ;
            foreach (var kv in predicateClustering)
            {
                if (kv.Value.Count > Variable.VariableSingle)
                {
                    clusteringHistory[(clusteringHistory.Count + Variable.VariableSingle).ToString()] = kv.Value;
                }
            }
        }