public static IList <Statement> GetCorrespondingAlignedStatementsByConclusion(Conclusion conclusion, IList <Statement> statementList, out IList <Statement> sortedStatementList) { sortedStatementList = null; IList <Statement> correspondingAlignedList = new List <Statement>(); var isAllStatementsConsidered = false; if (conclusion.Subject == conclusion.Predicate) { return(null); } IList <Statement> sortedList = GetSortedStatementsByConclusion(conclusion, statementList); correspondingAlignedList.Clear(); switch (sortedList.Count) { case 1: correspondingAlignedList.Add(sortedList[0]); //===>HERE CORRESPONDING ALIGNEDLIST AND SORTED LIST ARE SAME break; case 2: if (!IAERule.CheckStatementsCanBeAligned(sortedList[0], sortedList[1])) { isAllStatementsConsidered = true; } else { correspondingAlignedList.Add(sortedList[0]); correspondingAlignedList.Add(sortedList[1]); } break; case 3: //==>Split statememts into 3 Pairs StatementPair Pair1 = new StatementPair(sortedList[0], sortedList[1]); StatementPair Pair2 = new StatementPair(sortedList[1], sortedList[2]); StatementPair Pair3 = new StatementPair(sortedList[0], sortedList[2]); StatementPair resultPair = GetCorrespondingPairByStatementPairs(Pair1, Pair2, Pair3, conclusion); if (resultPair != null) { correspondingAlignedList.Add(resultPair.Statement1); correspondingAlignedList.Add(resultPair.Statement2); } else { isAllStatementsConsidered = true; } break; } if (correspondingAlignedList.Count == 0 || isAllStatementsConsidered) { correspondingAlignedList.Clear(); correspondingAlignedList.Add(statementList[0]); correspondingAlignedList.Add(statementList[1]); correspondingAlignedList.Add(statementList[2]); } SortedStatementList = sortedStatementList = sortedList; //==>Populate sorted list property and return in out paramaeter CorrespondingAlignedStatements = correspondingAlignedList; //==>populate corresponding aligned statements from sorted list return(correspondingAlignedList); }
public static Statement Add(Statement statement1, Statement statement2) { var TYPE1 = statement1.PropositionType; var TYPE2 = statement2.PropositionType; var STATEMENT1 = statement1.StatementName; var STATEMENT2 = statement2.StatementName; var result = string.Empty; if (!(IAERule.CheckStatementsCanBeAligned(statement1, statement2))) { return(null); //==>if the statements to be added cannot be aligned then it should retun null [for safety]; } if (TYPE1 == "A" && TYPE2 == "A") { //return "A"; result = AType.GetPropositionBySubjectAndPredicate(statement1.Subject, statement2.Predicate); return(new Statement(result)); } else if (TYPE1 == "A" && TYPE2 == "E") { //return "E"; result = EType.GetPropositionBySubjectAndPredicate(statement1.Subject, statement2.Predicate); return(new Statement(result)); } else if (TYPE1 == "E" && TYPE2 == "A") { //return "O*"; result = OType.GetStatementBySubjectAndPredicate(statement2.Predicate, statement1.Subject); return(new Statement(result)); } else if (TYPE1 == "E" && TYPE2 == "I") { //return "O*"; result = OType.GetStatementBySubjectAndPredicate(statement2.Predicate, statement1.Subject); return(new Statement(result)); } else if (TYPE1 == "I" && TYPE2 == "A") { // return "I"; result = IType.GetStatementBySubjectAndPredicate(statement1.Subject, statement2.Predicate); return(new Statement(result)); } else if (TYPE1 == "I" && TYPE2 == "E") { // return "O"; result = OType.GetStatementBySubjectAndPredicate(statement1.Subject, statement2.Predicate); return(new Statement(result)); } else if (TYPE1 == "A" && TYPE2 == "I") { return(null); //Convert "I" + "A"; // return "I"; //result = IType.GetStatementBySubjectAndPredicate(statement2.Subject, // statement1.Predicate); // return new Statement(result); //Had to implement rearranging order } return(null); }