protected override void readResults(int taskID, long allObjectsCount, object taskDescription, out GeneratingStruct generation, out HypothesisStruct[] result) { generation = common.GetGeneratingStruct(taskID); List<HypothesisStruct> hypothesesResult = new List<HypothesisStruct>(); HypothesisStruct hypothesisStruct; AbstractQuantifierSetting quantifierSetting; DataTable hypothesis = common.ExecuteSelectQuery("SELECT * FROM tiHypothesisCF WHERE TaskID=" + taskID); LiteralStruct[] literals = common.GetCategorialLiterals(TaskTypeEnum.CF, taskID, taskDescription); foreach (DataRow hypothese in hypothesis.Rows) { int hypothesisID = Convert.ToInt32(hypothese["HypothesisID"]); hypothesisStruct = new HypothesisStruct(); hypothesisStruct.booleanLiterals = common.GetBooleanLiterals(taskID, hypothesisID); int rowLiteralId = common.CategorialLiteral[Convert.ToInt32(hypothese["CFLiteralDID"])]; LiteralStruct rowLiteral = new LiteralStruct(); foreach (LiteralStruct literal in literals) { if (literal.cedentType == CedentEnum.Antecedent && literal.literalIdentifier == rowLiteralId) rowLiteral = literal; } hypothesisStruct.literals = new LiteralStruct[] { rowLiteral }; quantifierSetting = new AbstractQuantifierSetting(); quantifierSetting.firstContingencyTableRows = common.GetContingecyTable(this.taskType, taskID, hypothesisID, rowLiteral.literalIdentifier, rowLiteral.literalIdentifier); quantifierSetting.secondContingencyTableRows = new int[0][]; quantifierSetting.allObjectsCount = allObjectsCount; hypothesisStruct.quantifierSetting = quantifierSetting; hypothesesResult.Add(hypothesisStruct); } result = hypothesesResult.ToArray(); }
//private AbstractAttributeStruct GetAttribute(TaskTypeEnum taskType, object taskDescription, string attributeName, CedentEnum cedentType) //{ // switch (taskType) // { // case TaskTypeEnum.FFT: // break; // case TaskTypeEnum.KL: // /* // Ferda.Modules.Boxes.LISpMinerTasks.KLTask.TaskStruct input = (Ferda.Modules.Boxes.LISpMinerTasks.KLTask.TaskStruct)taskDescription; // if (cedentType == CedentEnum.Antecedent) // { // foreach (CategorialPartialCedentSettingStruct cedent in input.antecedentSetting) // { // foreach (AbstractAttributeStruct attribute in cedent.attributes) // { // if (attribute.nameInLiterals == attributeName) // return attribute; // } // } // } // else if (cedentType == CedentEnum.Succedent) // { // foreach (CategorialPartialCedentSettingStruct cedent in input.succedentSetting) // { // foreach (AbstractAttributeStruct attribute in cedent.attributes) // { // if (attribute.nameInLiterals == attributeName) // return attribute; // } // } // } // */ // break; // case TaskTypeEnum.CF: // Ferda.Modules.Boxes.LISpMinerTasks.CFTask.TaskStruct input1 = (Ferda.Modules.Boxes.LISpMinerTasks.CFTask.TaskStruct)taskDescription; // foreach (CategorialPartialCedentSettingStruct cedent in input1.antecedentSetting) // { // foreach (AbstractAttributeStruct attribute in cedent.attributes) // { // if (attribute.nameInLiterals == attributeName) // return attribute; // } // } // break; // case TaskTypeEnum.SDFFT: // break; // case TaskTypeEnum.SDKL: // /* // Ferda.Modules.Boxes.LISpMinerTasks.SDKLTask.TaskStruct input2 = (Ferda.Modules.Boxes.LISpMinerTasks.SDKLTask.TaskStruct)taskDescription; // if (cedentType == CedentEnum.Antecedent) // { // foreach (CategorialPartialCedentSettingStruct cedent in input2.antecedentSetting) // { // foreach (AbstractAttributeStruct attribute in cedent.attributes) // { // if (attribute.nameInLiterals == attributeName) // return attribute; // } // } // } // else if (cedentType == CedentEnum.Succedent) // { // foreach (CategorialPartialCedentSettingStruct cedent in input2.succedentSetting) // { // foreach (AbstractAttributeStruct attribute in cedent.attributes) // { // if (attribute.nameInLiterals == attributeName) // return attribute; // } // } // } // */ // break; // case TaskTypeEnum.SDCF: // Ferda.Modules.Boxes.LISpMinerTasks.SDCFTask.TaskStruct input3 = (Ferda.Modules.Boxes.LISpMinerTasks.SDCFTask.TaskStruct)taskDescription; // foreach (CategorialPartialCedentSettingStruct cedent in input3.antecedentSetting) // { // foreach (AbstractAttributeStruct attribute in cedent.attributes) // { // if (attribute.nameInLiterals == attributeName) // return attribute; // } // } // break; // default: // break; // } // return null; //} public LiteralStruct[] GetCategorialLiterals(TaskTypeEnum taskType, int taskID, object taskDescription) { string tdLiteralTableName = String.Empty; string tdLiteralIDColumn = String.Empty; string tdCedentDTableName = String.Empty; string tdCedentDIDColumn = String.Empty; switch (taskType) { case TaskTypeEnum.CF: case TaskTypeEnum.SDCF: tdLiteralTableName = "tdCFLiteralD"; tdLiteralIDColumn = "CFLiteralDID"; tdCedentDTableName = "tdCFCedentD"; tdCedentDIDColumn = "CFCedentDID"; break; case TaskTypeEnum.KL: case TaskTypeEnum.SDKL: tdLiteralTableName = "tdKLLiteralD"; tdLiteralIDColumn = "KLLiteralDID"; tdCedentDTableName = "tdKLCedentD"; tdCedentDIDColumn = "KLCedentDID"; break; default: throw new Exception("SwitchBranchNotImplemented"); } List<LiteralStruct> result = new List<LiteralStruct>(); LiteralStruct literalStruct; DataTable literals = ExecuteSelectQuery( "SELECT " + tdLiteralTableName + "." + tdLiteralIDColumn + ", " + tdCedentDTableName + "." + tdCedentDIDColumn + ", " + tdLiteralTableName + ".QuantityID, " + "tmQuantity.Name, CedentTypeID" + " FROM `" + tdCedentDTableName + "`, `" + tdLiteralTableName + "`, `tmQuantity` " + "WHERE TaskID=" + taskID + " AND " + tdCedentDTableName + "." + tdCedentDIDColumn + "=" + tdLiteralTableName + "." + tdCedentDIDColumn + " AND tmQuantity.QuantityID=" + tdLiteralTableName + "." + "QuantityID" ); foreach (DataRow literal in literals.Rows) { literalStruct = new LiteralStruct(); literalStruct.cedentType = Constants.CedentEnumDictionaryBackward[ Convert.ToInt32(literal["CedentTypeID"])]; literalStruct.literalIdentifier = CategorialLiteral[Convert.ToInt32(literal[tdLiteralIDColumn])]; //literalStruct.literalIdentifier = Convert.ToInt32(literal[tdLiteralIDColumn]); literalStruct.literalName = literal["Name"].ToString(); literalStruct.categoriesNames = GetCategorialLiteralCategoriesNames(Convert.ToInt32(literal["QuantityID"])); result.Add(literalStruct); } return result.ToArray(); }