Exemple #1
0
        public static void GenerateTripleRule()
        {
            Global.LocalStorage.LoadStorage();
            Dictionary <string, string> predicateSymbolDic = new Dictionary <string, string>();
            HashSet <string>            variableHistorical = new HashSet <string>();

            variableHistorical.Add(WordSet.Swan);
            variableHistorical.Add(WordSet.Lion);

            variableHistorical.Add(WordSet.Rhino);
            variableHistorical.Add(WordSet.Frog);



            List <RuleSetUnit> RuleCollection = new List <RuleSetUnit>();
            List <TrainingSet> trainDataList  = new List <TrainingSet>();

            for (int i = Variable.VariableZero; i < Variable.TaskCount; i++)
            {
                trainDataList.Add(new TrainingSet());
            }
            foreach (var task in Global.LocalStorage.TrainingSet_Accessor_Selector())
            {
                trainDataList[task.taskIndex - Variable.VariableSingle] = task;
            }
            int taskId = Variable.VariableZero;

            foreach (var trainingSet in trainDataList)
            {
                ++taskId;
                if (taskId != trainingSet.taskIndex)
                {
                    throw new Exception(Variable.WrongTaskID);
                }
                HandleFirstTask obj            = new HandleFirstTask(taskId, trainingSet.SessionSet);
                var             currentRuleSet = obj.PipeLine(ref predicateSymbolDic, ref variableHistorical, taskId);
                Tools.PrintResult(predicateSymbolDic, currentRuleSet, taskId.ToString());
                RuleCollection = UpdateRuleSet.Update(variableHistorical, RuleCollection);
                MergeRuleSet mergeObj         = new MergeRuleSet();
                var          mergedCollection = mergeObj.StoreRuleSet(currentRuleSet, RuleCollection);
                RuleCollection = new List <RuleSetUnit>(mergedCollection);
            }
            StoreRuleSet.StoreRuleCollection(predicateSymbolDic, variableHistorical, RuleCollection);
            Tools.PrintAll(predicateSymbolDic, RuleCollection);
        }
Exemple #2
0
        private List <List <RuleStructure> > ProcessSessions(List <List <ProcessingUnit> > sessionSet, ref HashSet <string> variableSet, int taskId)
        {
            int sessionCounter = Variable.VariableZero;
            List <List <RuleStructure> > ruleSet = new List <List <RuleStructure> >();

            foreach (var session in sessionSet)
            {
                ++sessionCounter;
                Console.WriteLine(sessionCounter);
                HashSet <string> currentSessionVariableSet = new HashSet <string>();
                var currentSessionRuleSet = ProcessEachSession(new List <ProcessingUnit>(session), ref currentSessionVariableSet);
                ruleSet.Add(currentSessionRuleSet);
                variableSet.UnionWith(currentSessionVariableSet);
            }
            var result = UpdateRuleSet.Update(variableSet, ruleSet);

            return(result);
        }