Ejemplo n.º 1
0
        private RuleStructure GenerateRule(List <ProcessingUnit> accumulation, QACombination currentQA, ref HashSet <string> variableHistorical, ref Dictionary <string, string> allVariableDic)
        {
            int questionLength = currentQA.Question.Count;
            List <KeyValuePair <string, VariableType> > qaStructure = new List <KeyValuePair <string, VariableType> >(currentQA.Question);

            qaStructure.AddRange(currentQA.Answer);
            Dictionary <string, string> variableTagger = new Dictionary <string, string>();
            Variable variable = new Variable();

            foreach (var ele in qaStructure)
            {
                if (ele.Value != VariableType.Unknown)
                {
                    if (!variableTagger.ContainsKey(ele.Key))
                    {
                        variableTagger[ele.Key] = variable.GetAvailiableVariableSymbol;
                    }
                    variableHistorical.Add(ele.Key);
                }
            }
            var ruleStructure = VariableTrans(variableTagger, accumulation, qaStructure, variableHistorical, questionLength, ref allVariableDic);

            return(ruleStructure);
        }
Ejemplo n.º 2
0
        private List <ProcessingUnit> GetCurrentQuestionAccumulation(List <ProcessingUnit> accumulativeFacts, QACombination currentQA)
        {
            var accumulativeFact = SortTimeElement(accumulativeFacts);
            List <KeyValuePair <string, VariableType> > QAStructure = new List <KeyValuePair <string, VariableType> >(currentQA.Question);
            List <int> indexList = new List <int>();

            QAStructure.AddRange(currentQA.Answer);
            for (int index = Variable.VariableZero; index < accumulativeFact.Count; index++)
            {
                foreach (var ele in QAStructure)
                {
                    if (accumulativeFact[index].GetSubjectValue.Contains(ele.Key))
                    {
                        if (Tools.IsWell(accumulativeFact[index].GetSubjectValue, ele.Key))
                        {
                            if (!indexList.Contains(index))
                            {
                                indexList.Add(index);
                            }
                        }
                    }
                    if (accumulativeFact[index].GetObjectValue.Contains(ele.Key))
                    {
                        if (Tools.IsWell(accumulativeFact[index].GetObjectValue, ele.Key))
                        {
                            if (!indexList.Contains(index))
                            {
                                indexList.Add(index);
                            }
                        }
                    }
                }
            }
            List <int> indexCopy = new List <int>(indexList);

            for (int i = Variable.VariableZero; i < accumulativeFact.Count; i++)
            {
                if (indexList.Contains(i))
                {
                    continue;
                }
                else
                {
                    foreach (var ele in indexCopy)
                    {
                        if (accumulativeFact[ele].GetSubjectValue == accumulativeFact[i].GetSubjectValue ||
                            accumulativeFact[ele].GetObjectValue == accumulativeFact[i].GetObjectValue)
                        {
                            if (!indexList.Contains(i))
                            {
                                indexList.Add(i);
                            }
                        }
                    }
                }
            }
            indexList.Sort();
            List <ProcessingUnit> result = new List <ProcessingUnit>();

            foreach (var unit in indexList)
            {
                result.Add(accumulativeFact[unit]);
            }
            return(result);
        }