Пример #1
0
        public void Remap(
            BooleanCedent[] booleanCedents,
            CategorialCedent[] categorialCedents,
            int taskID,
            TaskTypeEnum taskType,
            string boxIdentity,
            out long allRowsInTaskDataMatrixCount)
        {
            List<AbstractAttributeStruct> abstractAttributes = new List<AbstractAttributeStruct>();
            string categoryName;

            #region EQUIVALENCE CLASS PROBLEM VARIABLES
            int attributeIdentifier;
            int literalIdentifier;
            int equivalenceClassIdentifier;
            int rewrite;
            //Pair <attribute.identifier, List Of [literal.identifier]>
            Dictionary<int, List<int>> attributesAndLiterals = new Dictionary<int, List<int>>();
            //Pair <attribute.identifier, equivalenceClass.identifier>
            Dictionary<int, int> attributesAndEquivalenceClasses = new Dictionary<int, int>();
            //Pair <literal.identifier, equivalenceClass.identifier>
            Dictionary<int, int> literalsAndEquivalenceClasses = new Dictionary<int, int>();
            #endregion

            #region BooleanCedent (tdCedentD), EquivalenceClass (tdEquivalenceClass), Literal (tdLiteralD)

            Dictionary<CedentEnum, bool> savedCedents = new Dictionary<CedentEnum, bool>();

            if (booleanCedents != null)
            {
                int booleanCedentID;
                int equivalenceClassID;
                EquivalenceClassStruct[] equivalenceClasses;

                foreach (BooleanCedent booleanCedent in booleanCedents)
                {
                    #region BooleanPartialCedent (tdCedentD)
                    CedentIdentifierAndType cedentIdentifierAndType = new CedentIdentifierAndType(booleanCedent.Cedent.identifier, booleanCedent.CedentType);
                    if (this.booleanPartialCedents.ContainsKey(cedentIdentifierAndType))
                    {
                        booleanCedentID = this.booleanPartialCedents[cedentIdentifierAndType];
                        continue;
                    }
                    else
                    {
                        booleanCedentID = this.SetBooleanPartialCedent(
                            booleanCedent.CedentType,
                            booleanCedent.Cedent.minLen,
                            booleanCedent.Cedent.maxLen,
                            taskID);
                        this.booleanPartialCedents.Add(cedentIdentifierAndType, booleanCedentID);
                    }

                    savedCedents[booleanCedent.CedentType] = true;

                    #endregion

                    #region EQUIVALENCE CLASS PROBLEM

                    equivalenceClasses = booleanCedent.Cedent.equivalenceClasses;

                    if (equivalenceClasses != null &&
                        equivalenceClasses.Length > 0)
                    {
                        //This makes attributesAndLiterals Dictionary<int, List<int>> Pair <attribute.identifier, List Of [literal.identifier]>
                        if (booleanCedent.Cedent.literalSettings != null)
                            foreach (LiteralSettingStruct literalSettingStruct in booleanCedent.Cedent.literalSettings)
                            {
                                //literalSettingStruct.identifier;
                                attributeIdentifier = literalSettingStruct.atomSetting.abstractAttribute.identifier;
                                literalIdentifier = literalSettingStruct.identifier;
                                if (attributesAndLiterals.ContainsKey(attributeIdentifier))
                                    attributesAndLiterals[attributeIdentifier].Add(literalIdentifier);
                                else
                                    attributesAndLiterals.Add(attributeIdentifier, new List<int>(new int[] { literalIdentifier }));
                                attributesAndEquivalenceClasses[attributeIdentifier] = 0;
                                literalsAndEquivalenceClasses[literalIdentifier] = 0;
                            }
                        //This makes attributesAndEquivalenceClasses Dictionary<int, int> Pair <attribute.identifier, equivalenceClass.identifier>
                        foreach (EquivalenceClassStruct equivalenceClassStruct in equivalenceClasses)
                        {
                            equivalenceClassIdentifier = equivalenceClassStruct.identifier;
                            foreach (int identifierOfAttributeInClass in equivalenceClassStruct.attributesIdentifiers)
                            {
                                rewrite = 0;
                                if (attributesAndEquivalenceClasses.ContainsKey(identifierOfAttributeInClass))
                                {
                                    if (attributesAndEquivalenceClasses[identifierOfAttributeInClass] != 0)
                                        rewrite = attributesAndEquivalenceClasses[identifierOfAttributeInClass];
                                    attributesAndEquivalenceClasses[identifierOfAttributeInClass] = equivalenceClassIdentifier;
                                }
                                else
                                    attributesAndEquivalenceClasses.Add(identifierOfAttributeInClass, equivalenceClassIdentifier);
                                if (rewrite != 0)
                                    foreach (KeyValuePair<int, int> kvp in attributesAndEquivalenceClasses)
                                    {
                                        if (attributesAndEquivalenceClasses[kvp.Key] == rewrite)
                                            attributesAndEquivalenceClasses[kvp.Key] = equivalenceClassIdentifier;
                                    }
                            }
                        }
                        //This makes literalsAndEquivalenceClasses Dictionary<int, int> Pair <literal.identifier, equivalenceClass.identifier>
                        //Process equivalence classes of attributes to literals
                        foreach (KeyValuePair<int, int> kvp in attributesAndEquivalenceClasses)
                        {
                            if (attributesAndEquivalenceClasses[kvp.Key] != 0)
                            {
                                rewrite = attributesAndEquivalenceClasses[kvp.Key];
                                foreach (int currentLiteralKey in attributesAndLiterals[kvp.Key])
                                {
                                    literalsAndEquivalenceClasses[currentLiteralKey] = rewrite;
                                }
                            }
                        }
                        //This process equivalence classes of literals
                        foreach (EquivalenceClassStruct equivalenceClassStruct in equivalenceClasses)
                        {
                            equivalenceClassIdentifier = equivalenceClassStruct.identifier;
                            foreach (int identifierOfLiteralInClass in equivalenceClassStruct.literalsIdentifiers)
                            {
                                rewrite = 0;
                                if (literalsAndEquivalenceClasses.ContainsKey(identifierOfLiteralInClass))
                                {
                                    if (literalsAndEquivalenceClasses[identifierOfLiteralInClass] != 0)
                                        rewrite = literalsAndEquivalenceClasses[identifierOfLiteralInClass];
                                    literalsAndEquivalenceClasses[identifierOfLiteralInClass] = equivalenceClassIdentifier;
                                }
                                else
                                {
                                    literalsAndEquivalenceClasses.Add(identifierOfLiteralInClass, equivalenceClassIdentifier);
                                }
                                if (rewrite != 0)
                                    foreach (KeyValuePair<int, int> kvp in literalsAndEquivalenceClasses)
                                    {
                                        if (literalsAndEquivalenceClasses[kvp.Key] == rewrite)
                                            literalsAndEquivalenceClasses[kvp.Key] = equivalenceClassIdentifier;
                                    }
                            }
                        }
                    }

                    #endregion

                    #region EquivalenceClass (tdEquivalenceClass)

                    equivalenceClasses = booleanCedent.Cedent.equivalenceClasses;
                    if (booleanCedent.Cedent.equivalenceClasses != null)
                        foreach (EquivalenceClassStruct equivalenceClassStruct in equivalenceClasses)
                        {
                            //test if equivalence class is used or if it was absorb by other equivalence class
                            if (!literalsAndEquivalenceClasses.ContainsValue(equivalenceClassStruct.identifier))
                                continue;

                            equivalenceClassID = this.SetEquivalenceClass(
                                booleanCedentID,
                                equivalenceClassStruct.identifier);
                            this.equivalenceClasses.Add(equivalenceClassStruct.identifier, equivalenceClassID);
                        }

                    #endregion

                    #region  Prepare list of Attributes from BooleanCedents
                    if (booleanCedent.Cedent.literalSettings != null)
                        foreach (LiteralSettingStruct literalSettingStruct in booleanCedent.Cedent.literalSettings)
                        {
                            abstractAttributes.Add(literalSettingStruct.atomSetting.abstractAttribute);
                        }
                    #endregion
                }
            }
            #endregion
            #region Prepare list of Attributes from CategorialCedents
            if (categorialCedents != null)
                foreach (CategorialCedent categorialCedent in categorialCedents)
                {
                    savedCedents[categorialCedent.CedentType] = true;
                    abstractAttributes.AddRange(categorialCedent.Cedent.attributes);
                }
            #endregion

            #region Saved cedents?
            //pokud totiz neni nastaven nejaky cedent (chybi treba prazdny radek), tak nejde pustit gen
            switch (taskType)
            {
                case TaskTypeEnum.FFT:
                    if (!savedCedents.ContainsKey(CedentEnum.Antecedent) || savedCedents[CedentEnum.Antecedent] == false)
                        this.SetBooleanPartialCedent(CedentEnum.Antecedent, 0, 0, taskID);
                    if (!savedCedents.ContainsKey(CedentEnum.Succedent) || savedCedents[CedentEnum.Succedent] == false)
                        this.SetBooleanPartialCedent(CedentEnum.Succedent, 0, 0, taskID);
                    if (!savedCedents.ContainsKey(CedentEnum.Condition) || savedCedents[CedentEnum.Condition] == false)
                        this.SetBooleanPartialCedent(CedentEnum.Condition, 0, 0, taskID);
                    break;
                case TaskTypeEnum.SDFFT:
                    if (!savedCedents.ContainsKey(CedentEnum.Antecedent) || savedCedents[CedentEnum.Antecedent] == false)
                        this.SetBooleanPartialCedent(CedentEnum.Antecedent, 0, 0, taskID);
                    if (!savedCedents.ContainsKey(CedentEnum.Succedent) || savedCedents[CedentEnum.Succedent] == false)
                        this.SetBooleanPartialCedent(CedentEnum.Succedent, 0, 0, taskID);
                    if (!savedCedents.ContainsKey(CedentEnum.Condition) || savedCedents[CedentEnum.Condition] == false)
                        this.SetBooleanPartialCedent(CedentEnum.Condition, 0, 0, taskID);
                    if (!savedCedents.ContainsKey(CedentEnum.FirstSet) || savedCedents[CedentEnum.FirstSet] == false)
                        this.SetBooleanPartialCedent(CedentEnum.FirstSet, 0, 0, taskID);
                    if (!savedCedents.ContainsKey(CedentEnum.SecondSet) || savedCedents[CedentEnum.SecondSet] == false)
                        this.SetBooleanPartialCedent(CedentEnum.SecondSet, 0, 0, taskID);
                    break;
                case TaskTypeEnum.KL:
                    if (!savedCedents.ContainsKey(CedentEnum.Antecedent) || savedCedents[CedentEnum.Antecedent] == false)
                        this.SetCategorialPartialCedent(CedentEnum.Antecedent, 0, 0, taskID, taskType);
                    if (!savedCedents.ContainsKey(CedentEnum.Succedent) || savedCedents[CedentEnum.Succedent] == false)
                        this.SetCategorialPartialCedent(CedentEnum.Succedent, 0, 0, taskID, taskType);
                    if (!savedCedents.ContainsKey(CedentEnum.Condition) || savedCedents[CedentEnum.Condition] == false)
                        this.SetBooleanPartialCedent(CedentEnum.Condition, 0, 0, taskID);
                    break;

                case TaskTypeEnum.CF:
                    if (!savedCedents.ContainsKey(CedentEnum.Antecedent) || savedCedents[CedentEnum.Antecedent] == false)
                        this.SetCategorialPartialCedent(CedentEnum.Antecedent, 0, 0, taskID, taskType);
                    if (!savedCedents.ContainsKey(CedentEnum.Condition) || savedCedents[CedentEnum.Condition] == false)
                        this.SetBooleanPartialCedent(CedentEnum.Condition, 0, 0, taskID);
                    break;

                case TaskTypeEnum.SDCF:
                    if (!savedCedents.ContainsKey(CedentEnum.Antecedent) || savedCedents[CedentEnum.Antecedent] == false)
                        this.SetCategorialPartialCedent(CedentEnum.Antecedent, 0, 0, taskID, taskType);
                    if (!savedCedents.ContainsKey(CedentEnum.Condition) || savedCedents[CedentEnum.Condition] == false)
                        this.SetBooleanPartialCedent(CedentEnum.Condition, 0, 0, taskID);
                    if (!savedCedents.ContainsKey(CedentEnum.FirstSet) || savedCedents[CedentEnum.FirstSet] == false)
                        this.SetBooleanPartialCedent(CedentEnum.FirstSet, 0, 0, taskID);
                    if (!savedCedents.ContainsKey(CedentEnum.SecondSet) || savedCedents[CedentEnum.SecondSet] == false)
                        this.SetBooleanPartialCedent(CedentEnum.SecondSet, 0, 0, taskID);
                    break;

                case TaskTypeEnum.SDKL:
                    if (!savedCedents.ContainsKey(CedentEnum.Antecedent) || savedCedents[CedentEnum.Antecedent] == false)
                        this.SetCategorialPartialCedent(CedentEnum.Antecedent, 0, 0, taskID, taskType);
                    if (!savedCedents.ContainsKey(CedentEnum.Succedent) || savedCedents[CedentEnum.Succedent] == false)
                        this.SetCategorialPartialCedent(CedentEnum.Succedent, 0, 0, taskID, taskType);
                    if (!savedCedents.ContainsKey(CedentEnum.Condition) || savedCedents[CedentEnum.Condition] == false)
                        this.SetBooleanPartialCedent(CedentEnum.Condition, 0, 0, taskID);
                    if (!savedCedents.ContainsKey(CedentEnum.FirstSet) || savedCedents[CedentEnum.FirstSet] == false)
                        this.SetBooleanPartialCedent(CedentEnum.FirstSet, 0, 0, taskID);
                    if (!savedCedents.ContainsKey(CedentEnum.SecondSet) || savedCedents[CedentEnum.SecondSet] == false)
                        this.SetBooleanPartialCedent(CedentEnum.SecondSet, 0, 0, taskID);
                    break;

                default:
                    throw Ferda.Modules.Exceptions.SwitchCaseNotImplementedError(taskType);
            }
            #endregion

            #region DataMatrix (tmMatrix), Columns (tmAttribute), AbstractAttributes (tmQuantity), Category (tmCategory, tmCategoryEnumValue, tmInterval, tmValue)

            string dataMatrixName = "";
            int dataMatrixDBID = 0;
            string[] primaryKeyColumns = null; //must be sorted (for BinarySearch)
            string connectionString = null;
            allRowsInTaskDataMatrixCount = 0;
            ColumnSchemaInfo[] columnSchemaInfoSeq = null;
            Ferda.Modules.Boxes.DataMiningCommon.DataMatrix.DataMatrixInfo dataMatrixInfo;

            #region DataMatrix (tmMatrix)
            {
                AbstractAttributeStruct abstractAttributeStruct = abstractAttributes[0];
                dataMatrixInfo = abstractAttributeStruct.column.dataMatrix;

                //only for first attribute/column ... each attribute in one task must be in one and only one data matrix
                columnSchemaInfoSeq = dataMatrixInfo.explainDataMatrix;
                dataMatrixName = dataMatrixInfo.dataMatrixName;
                dataMatrixDBID = SetDataMatrix(dataMatrixName, dataMatrixInfo.recordsCount);
                updateTask(taskID, dataMatrixDBID);

                allRowsInTaskDataMatrixCount = dataMatrixInfo.recordsCount;

                string connectionStringForSave = dataMatrixInfo.database.odbcConnectionString.Trim();
                if (connectionStringForSave.StartsWith("DSN=", StringComparison.InvariantCultureIgnoreCase))
                    connectionStringForSave = connectionStringForSave.Substring(4);

                ExecuteUpdateQuery(
                    "UPDATE tpParamsDB SET "
                    + " strValue='" + connectionStringForSave + "' "
                    + " WHERE Name='DSN'");

                connectionString = dataMatrixInfo.database.odbcConnectionString;
                primaryKeyColumns = dataMatrixInfo.primaryKeyColumns;
                Array.Sort(primaryKeyColumns);
            }

            //Test values of primary key columns for duplicits (also test connection string and existence of data matrix)
            Ferda.Modules.Helpers.Data.DataMatrix.TestValuesInEnteredPrimaryKeyColumnsAreNotUniqueError(connectionString, dataMatrixName, primaryKeyColumns, boxIdentity);
            #endregion

            ColumnInfo columnInfo;
            CategoriesStruct categories;
            int columnID;
            int columnThereforeAlsoAttributeValueSubTypeDBID = 0;
            string columnSelectExpression;
            int primaryKeyColumnPosition;
            int categoryID;
            int enumCategoryValueID;
            int attributeID;
            //int attributeIdentifier; --allready defined
            string xCategory;
            string includeNullCategory;

            foreach (AbstractAttributeStruct abstractAttributeStruct in abstractAttributes)
            {
                //Protect from multiple saving columns or attributesAndEquivalenceClasses or caregories
                if (this.attributes.ContainsKey(abstractAttributeStruct.identifier))
                    continue;

                #region Columns (tmAttribute)

                if (dataMatrixName != abstractAttributeStruct.column.dataMatrix.dataMatrixName)
                {
                    throw Ferda.Modules.Exceptions.BoxRuntimeError(null, boxIdentity, "LM Task can not run over more than one datamatrix!");
                }
                columnSelectExpression = abstractAttributeStruct.column.columnSelectExpression;

                //Protect from multiple saving columns
                if (this.columns.ContainsKey(columnSelectExpression))
                {
                    columnID = this.columns[columnSelectExpression];
                }
                else
                {
                    columnInfo = abstractAttributeStruct.column;
                    primaryKeyColumnPosition = Array.BinarySearch(primaryKeyColumns, abstractAttributeStruct.column.columnSelectExpression);
                    columnThereforeAlsoAttributeValueSubTypeDBID = this.constants.ValueSubTypeEnumDictionary[columnInfo.columnSubType];
                    columnID = SetColumn(
                        columnInfo.columnSelectExpression,
                        dataMatrixDBID,
                        columnInfo.columnType,
                        columnInfo.columnSubType,
                        columnSelectExpression,
                        (primaryKeyColumnPosition >= 0) ? primaryKeyColumnPosition + 1 : -1);
                    this.columns.Add(columnInfo.columnSelectExpression, columnID);
                }

                int i = 0;
                foreach (string primaryKeyColumn in primaryKeyColumns)
                {
                    i++;
                    if (String.IsNullOrEmpty(primaryKeyColumn))
                        continue;
                    if (this.columns.ContainsKey(primaryKeyColumn))
                        continue;
                    foreach (ColumnSchemaInfo columnSchemaInfo in columnSchemaInfoSeq)
                    {
                        if (columnSchemaInfo.name == primaryKeyColumn)
                        {
                            int tmpColumnID = SetColumn(
                                columnSchemaInfo.name,
                                dataMatrixDBID,
                                ColumnTypeEnum.Ordinary,
                                Ferda.Modules.Helpers.Data.Column.GetColumnSubTypeByDataType(columnSchemaInfo.dataType),
                                columnSchemaInfo.name,
                                i);
                            this.columns.Add(columnSchemaInfo.name, tmpColumnID);
                            break;
                        }
                    }
                }

                #endregion

                #region Attribute (tmQuantity)

                attributeID = SetAttribute(
                        abstractAttributeStruct.nameInLiterals,
                        abstractAttributeStruct.identifier,
                        columnID);
                attributeIdentifier = abstractAttributeStruct.identifier;
                xCategory = abstractAttributeStruct.xCategory;
                includeNullCategory = abstractAttributeStruct.includeNullCategory;
                this.attributesCache.Add(abstractAttributeStruct.identifier, abstractAttributeStruct);
                this.attributes.Add(attributeIdentifier, attributeID);
                this.categories.Add(attributeIdentifier, new Dictionary<string, int>());
                this.categoriesOrds.Add(attributeIdentifier, new Dictionary<long, string>());

                #endregion

                #region Categories (tmCategory, tmCategoryEnumValue, tmInterval, tmValue)

                long categoryOrd = 0;
                categories = abstractAttributeStruct.categories;
                //if (categories.dateTimeIntervals != null)
                foreach (DictionaryEntry category in categories.dateTimeIntervals)
                {
                    categoryName = (string)category.Key;
                    //tmCategory
                    categoryOrd++;
                    categoryID = SetCategory(
                        categoryName,
                        attributeID,
                        CategoryTypeEnum.Interval,
                        (xCategory == categoryName),
                        (includeNullCategory == categoryName),
                        categoryOrd,
                        attributeIdentifier);
                    //tmValue, tmInterval
                    foreach (DateTimeIntervalStruct intervalStruct in (DateTimeIntervalStruct[])category.Value)
                    {
                        insertValueInterval(categoryID, intervalStruct);
                    }
                }
                //if (categories.floatIntervals != null)
                foreach (DictionaryEntry category in categories.floatIntervals)
                {
                    categoryName = (string)category.Key;
                    //tmCategory
                    categoryOrd++;
                    categoryID = SetCategory(
                        categoryName,
                        attributeID,
                        CategoryTypeEnum.Interval,
                        (xCategory == categoryName),
                        (includeNullCategory == categoryName),
                        categoryOrd,
                        attributeIdentifier);
                    //tmValue, tmInterval
                    foreach (FloatIntervalStruct intervalStruct in (FloatIntervalStruct[])category.Value)
                    {
                        insertValueInterval(categoryID, intervalStruct);
                    }
                }
                //if (categories.longIntervals != null)
                foreach (DictionaryEntry category in categories.longIntervals)
                {
                    categoryName = (string)category.Key;
                    //tmCategory
                    categoryOrd++;
                    categoryID = SetCategory(
                        categoryName,
                        attributeID,
                        CategoryTypeEnum.Interval,
                        (xCategory == categoryName),
                        (includeNullCategory == categoryName),
                        categoryOrd,
                        attributeIdentifier);
                    //tmValue, tmInterval
                    foreach (LongIntervalStruct intervalStruct in (LongIntervalStruct[])category.Value)
                    {
                        insertValueInterval(categoryID, intervalStruct);
                    }
                }
                //if (categories.enums != null)
                foreach (DictionaryEntry category in categories.enums)
                {
                    categoryName = (string)category.Key;
                    //tmCategory
                    categoryOrd++;
                    categoryID = SetCategory(
                        categoryName,
                        attributeID,
                        CategoryTypeEnum.Enumeration,
                        (xCategory == categoryName),
                        (includeNullCategory == categoryName),
                        categoryOrd,
                        attributeIdentifier);
                    foreach (string enumItem in (string[])category.Value)
                    {
                        //tmValue
                        if (categoryName == includeNullCategory && String.IsNullOrEmpty(enumItem))
                        {
                            enumCategoryValueID = SetValue();
                            continue;
                        }
                        else if (String.IsNullOrEmpty(enumItem))
                        {
                            //DEBUG NOTES: for debugin purposes it can be usevull if this else-if branch is removed (commented)
                            enumCategoryValueID = SetValue();
                            continue;
                        }
                        switch (columnThereforeAlsoAttributeValueSubTypeDBID)
                        {
                            case 1: //long
                                enumCategoryValueID = SetValue(Convert.ToInt64(enumItem));
                                break;
                            case 2: //double
                                enumCategoryValueID = SetValue(Convert.ToDouble(enumItem));
                                break;
                            case 3: //string
                                enumCategoryValueID = SetValue(enumItem);
                                break;
                            case 4: //bool
                                enumCategoryValueID = SetValue(Convert.ToBoolean(enumItem));
                                break;
                            case 5: //date
                                enumCategoryValueID = SetValue(Convert.ToDateTime(enumItem));
                                break;
                            default:
                                throw Ferda.Modules.Exceptions.SwitchCaseNotImplementedError(columnThereforeAlsoAttributeValueSubTypeDBID);
                        }
                        //tmCategoryEnumValue
                        this.SetCategoryEnum(
                            categoryID,
                            enumCategoryValueID);
                    }
                }

                #endregion
            }

            #endregion

            #region CategorialCedent (tdKLCedentD, tdCFCedentD, tdKLLiteralD, tdCFLiteralD)

            int categorialCedentID;
            int categorialLiteralID;

            if (categorialCedents != null)
                foreach (CategorialCedent categorialCedent in categorialCedents)
                {
                    CedentIdentifierAndType cedentIdentifierAndType = new CedentIdentifierAndType(categorialCedent.Cedent.identifier, categorialCedent.CedentType);
                    if (this.categorialPartialCedent.ContainsKey(cedentIdentifierAndType))
                    {
                        categorialCedentID = this.categorialPartialCedent[cedentIdentifierAndType];
                    }
                    else
                    {
                        categorialCedentID = SetCategorialPartialCedent(
                            categorialCedent.CedentType,
                            categorialCedent.Cedent.minLen,
                            categorialCedent.Cedent.maxLen,
                            taskID,
                            taskType);
                        this.categorialPartialCedent.Add(cedentIdentifierAndType, categorialCedentID);

                        if (categorialCedent.Cedent.attributes != null)
                            foreach (AbstractAttributeStruct abstractAttributeStruct in categorialCedent.Cedent.attributes)
                            {
                                categorialLiteralID = SetCategorialLiteralSetting(
                                    categorialCedentID,
                                    this.attributes[abstractAttributeStruct.identifier],
                                    taskType,
                                    abstractAttributeStruct.identifier);
                            }
                    }
                }

            #endregion

            #region BooleanCedent (tdLiteralD)

            int literalID;

            if (booleanCedents != null)
            {
                foreach (BooleanCedent booleanCedent in booleanCedents)
                {
                    if (booleanCedent.Cedent.literalSettings != null)
                        foreach (LiteralSettingStruct literalSettingStruct in booleanCedent.Cedent.literalSettings)
                        {
                            int literalOneCategoryDBID = (literalSettingStruct.atomSetting.category.Length > 0)
                                ? this.categories[literalSettingStruct.atomSetting.abstractAttribute.identifier][literalSettingStruct.atomSetting.category[0]]
                                : 0;
                            int literalEquivalenceClass = 0;
                            try
                            {
                                literalEquivalenceClass = this.equivalenceClasses[literalsAndEquivalenceClasses[literalSettingStruct.identifier]];
                            }
                            catch (KeyNotFoundException) { }
                            literalID = this.SetLiteralSetting(
                                    literalSettingStruct.atomSetting.minLen,
                                    literalSettingStruct.atomSetting.maxLen,
                                    literalSettingStruct.atomSetting.coefficientType,
                                    literalEquivalenceClass,
                                    literalSettingStruct.gaceType,
                                    literalSettingStruct.literalType,
                                    literalOneCategoryDBID,
                                    this.booleanPartialCedents[new CedentIdentifierAndType(booleanCedent.Cedent.identifier, booleanCedent.CedentType)],
                                    this.attributes[literalSettingStruct.atomSetting.abstractAttribute.identifier]);
                            this.literals.Add(literalID, literalSettingStruct.identifier);
                            this.attributeNameInLiterals.Add(literalID, literalSettingStruct.atomSetting.abstractAttribute.nameInLiterals);
                            //abstractAttributes.Add(literalSettingStruct.atomSetting.abstractAttribute);
                        }
                }
            }

            #endregion
        }
Пример #2
0
 protected void addCategorialCedent(CategorialPartialCedentSettingStruct[] categorialPartialCedents, CedentEnum cedentType, ref List<CategorialCedent> categorialCedents)
 {
     CategorialCedent categorialCedent;
     if (categorialPartialCedents != null && categorialPartialCedents.Length > 0)
         foreach (CategorialPartialCedentSettingStruct categorialPartialCedentSetting in categorialPartialCedents)
         {
             categorialCedent = new CategorialCedent(cedentType, categorialPartialCedentSetting);
             categorialCedents.Add(categorialCedent);
         }
 }