当前位置: 首页>>代码示例>>C#>>正文


C# IMatrixData.GetCategoryColumnEntryAt方法代码示例

本文整理汇总了C#中IMatrixData.GetCategoryColumnEntryAt方法的典型用法代码示例。如果您正苦于以下问题:C# IMatrixData.GetCategoryColumnEntryAt方法的具体用法?C# IMatrixData.GetCategoryColumnEntryAt怎么用?C# IMatrixData.GetCategoryColumnEntryAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMatrixData的用法示例。


在下文中一共展示了IMatrixData.GetCategoryColumnEntryAt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessData

        public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
			ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            string colName = param.GetParam<string>("Name of new column").Value;
            int[] columns = param.GetParam<int[]>("Categories").Value;
            bool inverse = param.GetParam<bool>("Inverse").Value;
            int[] catCols;
            int[] stringCols;
            Split(columns, out catCols, out stringCols, mdata.CategoryColumnCount);
            string[] word1 = param.GetParam<string[]>("Search terms").Value;
            if (word1.Length == 0){
                processInfo.ErrString = "Please specify one or more search terms.";
                return;
            }
            if (string.IsNullOrEmpty(colName)){
                colName = word1[0];
            }
            string[] word = new string[word1.Length];
            for (int i = 0; i < word.Length; i++){
                word[i] = word1[i].ToLower().Trim();
            }
            bool[] indicator = new bool[mdata.RowCount];
            foreach (int col in catCols){
                for (int i = 0; i < mdata.RowCount; i++){
                    foreach (string s in mdata.GetCategoryColumnEntryAt(col, i)){
                        foreach (string s1 in word){
                            if (s.ToLower().Contains(s1)){
                                indicator[i] = true;
                                break;
                            }
                        }
                    }
                }
            }
            foreach (string[] txt in stringCols.Select(col => mdata.StringColumns[col])){
                for (int i = 0; i < txt.Length; i++){
                    string s = txt[i];
                    foreach (string s1 in word){
                        if (s.ToLower().Contains(s1)){
                            indicator[i] = true;
                            break;
                        }
                    }
                }
            }
            string[][] newCol = new string[indicator.Length][];
            for (int i = 0; i < newCol.Length; i++){
                bool yes = inverse ? !indicator[i] : indicator[i];
                newCol[i] = yes ? new[]{"+"} : new string[0];
            }
            mdata.AddCategoryColumn(colName, "", newCol);
        }
开发者ID:JurgenCox,项目名称:perseus-plugins,代码行数:52,代码来源:CombineAnnotations.cs

示例2: WriteMatrixToFile


//.........这里部分代码省略.........
         }
         for (int i = 0; i < data.NumericColumnCount; i++)
         {
             words.Add("N");
         }
         for (int i = 0; i < data.StringColumnCount; i++)
         {
             words.Add("T");
         }
         for (int i = 0; i < data.MultiNumericColumnCount; i++)
         {
             words.Add("M");
         }
         writer.WriteLine("#!{Type}" + StringUtils.Concat("\t", words));
         for (int i = 0; i < data.NumericRowCount; i++)
         {
             words = new List<string>();
             for (int j = 0; j < data.ColumnCount; j++)
             {
                 words.Add("" + data.NumericRows[i][j]);
             }
             for (int j = 0; j < data.CategoryColumnCount; j++)
             {
                 words.Add("");
             }
             for (int j = 0; j < data.NumericColumnCount; j++)
             {
                 words.Add("");
             }
             for (int j = 0; j < data.StringColumnCount; j++)
             {
                 words.Add("");
             }
             for (int j = 0; j < data.MultiNumericColumnCount; j++)
             {
                 words.Add("");
             }
             writer.WriteLine("#!{N:" + data.NumericRowNames[i] + "}" + StringUtils.Concat("\t", words));
         }
         for (int i = 0; i < data.CategoryRowCount; i++)
         {
             words = new List<string>();
             for (int j = 0; j < data.ColumnCount; j++)
             {
                 string[] s = data.GetCategoryRowAt(i)[j];
                 words.Add(s.Length == 0 ? "" : StringUtils.Concat(";", s));
             }
             for (int j = 0; j < data.CategoryColumnCount; j++)
             {
                 words.Add("");
             }
             for (int j = 0; j < data.NumericColumnCount; j++)
             {
                 words.Add("");
             }
             for (int j = 0; j < data.StringColumnCount; j++)
             {
                 words.Add("");
             }
             for (int j = 0; j < data.MultiNumericColumnCount; j++)
             {
                 words.Add("");
             }
             writer.WriteLine("#!{C:" + data.CategoryRowNames[i] + "}" + StringUtils.Concat("\t", words));
         }
         for (int j = 0; j < data.RowCount; j++)
         {
             words = new List<string>();
             for (int i = 0; i < data.ColumnCount; i++)
             {
                 string s1 = "" + data.Values.Get(j, i);
                 if (addtlMatrices)
                 {
                     s1 += ";" + data.IsImputed[j, i] + ";" + data.Quality.Get(j, i);
                 }
                 words.Add(s1);
             }
             for (int i = 0; i < data.CategoryColumnCount; i++)
             {
                 string[] q = data.GetCategoryColumnEntryAt(i, j) ?? new string[0];
                 words.Add((q.Length > 0 ? StringUtils.Concat(";", q) : ""));
             }
             for (int i = 0; i < data.NumericColumnCount; i++)
             {
                 words.Add("" + data.NumericColumns[i][j]);
             }
             for (int i = 0; i < data.StringColumnCount; i++)
             {
                 words.Add(data.StringColumns[i][j]);
             }
             for (int i = 0; i < data.MultiNumericColumnCount; i++)
             {
                 double[] q = data.MultiNumericColumns[i][j];
                 words.Add((q.Length > 0 ? StringUtils.Concat(";", q) : ""));
             }
             string s = StringUtils.Concat("\t", words);
             writer.WriteLine(s);
         }
     }
 }
开发者ID:JurgenCox,项目名称:perseus-plugins,代码行数:101,代码来源:PerseusUtils.cs

示例3: ProcessData

        public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
			ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            ParameterWithSubParams<int> p = param.GetParamWithSubParams<int>("Column");
            int colInd = p.Value;
            if (colInd < 0){
                processInfo.ErrString = "No categorical columns available.";
                return;
            }
            Parameter<int[]> mcp = p.GetSubParameters().GetParam<int[]>("Values");
            int[] inds = mcp.Value;
            if (inds.Length == 0){
                processInfo.ErrString = "Please select at least one term for filtering.";
                return;
            }
            string[] values = new string[inds.Length];
            string[] v = mdata.GetCategoryColumnValuesAt(colInd);
            for (int i = 0; i < values.Length; i++){
                values[i] = v[inds[i]];
            }
            HashSet<string> value = new HashSet<string>(values);
            bool remove = param.GetParam<int>("Mode").Value == 0;
            List<int> valids = new List<int>();
            for (int i = 0; i < mdata.RowCount; i++){
                bool valid = true;
                foreach (string w in mdata.GetCategoryColumnEntryAt(colInd, i)){
                    if (value.Contains(w)){
                        valid = false;
                        break;
                    }
                }
                if ((valid && remove) || (!valid && !remove)){
                    valids.Add(i);
                }
            }
            PerseusPluginUtils.FilterRows(mdata, param, valids.ToArray());
        }
开发者ID:JurgenCox,项目名称:perseus-plugins,代码行数:37,代码来源:FilterCategoricalColumn.cs

示例4: ProcessData

        public void ProcessData(IMatrixData mdata, Parameters param1, ref IMatrixData[] supplTables,
			ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            int[] multiNumCols = param1.GetParam<int[]>("Multi-numeric columns").Value;
            Array.Sort(multiNumCols);
            int[] stringCols = param1.GetParam<int[]>("Text columns").Value;
            Array.Sort(stringCols);
            HashSet<int> multinumCols2 = new HashSet<int>(multiNumCols);
            HashSet<int> stringCols2 = new HashSet<int>(stringCols);
            if (multiNumCols.Length + stringCols.Length == 0){
                processInfo.ErrString = "Please select some columns.";
                return;
            }
            int rowCount = GetNewRowCount(mdata, multiNumCols, stringCols);
            float[,] expVals = new float[rowCount, mdata.ColumnCount];
            List<string[]> stringC = new List<string[]>();
            for (int i = 0; i < mdata.StringColumnCount; i++){
                stringC.Add(new string[rowCount]);
            }
            List<double[]> numC = new List<double[]>();
            for (int i = 0; i < mdata.NumericColumnCount; i++){
                numC.Add(new double[rowCount]);
            }
            List<string[][]> catC = new List<string[][]>();
            for (int i = 0; i < mdata.CategoryColumnCount; i++){
                catC.Add(new string[rowCount][]);
            }
            List<double[][]> multiNumC = new List<double[][]>();
            for (int i = 0; i < mdata.MultiNumericColumnCount; i++){
                multiNumC.Add(new double[rowCount][]);
            }
            int count = 0;
            for (int i = 0; i < mdata.RowCount; i++){
                string err;
                int entryCount = GetEntryCount(i, mdata, multiNumCols, stringCols, out err);
                if (err != null){
                    processInfo.ErrString = err;
                    return;
                }
                bool empty = entryCount == 0;
                entryCount = Math.Max(entryCount, 1);
                for (int j = 0; j < entryCount; j++){
                    for (int k = 0; k < mdata.ColumnCount; k++){
                        expVals[count + j, k] = mdata.Values.Get(i, k);
                    }
                    for (int k = 0; k < mdata.NumericColumnCount; k++){
                        numC[k][count + j] = mdata.NumericColumns[k][i];
                    }
                    for (int k = 0; k < mdata.CategoryColumnCount; k++){
                        catC[k][count + j] = mdata.GetCategoryColumnEntryAt(k, i);
                    }
                }
                for (int k = 0; k < mdata.MultiNumericColumnCount; k++){
                    if (multinumCols2.Contains(k)){
                        if (empty){
                            multiNumC[k][count] = new double[0];
                        } else{
                            double[] vals = mdata.MultiNumericColumns[k][i];
                            for (int j = 0; j < entryCount; j++){
                                multiNumC[k][count + j] = new[]{vals[j]};
                            }
                        }
                    } else{
                        for (int j = 0; j < entryCount; j++){
                            multiNumC[k][count + j] = mdata.MultiNumericColumns[k][i];
                        }
                    }
                }
                for (int k = 0; k < mdata.StringColumnCount; k++){
                    if (stringCols2.Contains(k)){
                        if (empty){
                            stringC[k][count] = "";
                        } else{
                            string[] vals = mdata.StringColumns[k][i].Split(';');
                            for (int j = 0; j < entryCount; j++){
                                stringC[k][count + j] = vals[j];
                            }
                        }
                    } else{
                        for (int j = 0; j < entryCount; j++){
                            stringC[k][count + j] = mdata.StringColumns[k][i];
                        }
                    }
                }
                count += entryCount;
            }
            int[] multiNumComplement = ArrayUtils.Complement(multiNumCols, mdata.MultiNumericColumnCount);
            List<double[][]> toBeTransformed = ArrayUtils.SubList(multiNumC, multiNumCols);
            multiNumC = ArrayUtils.SubList(multiNumC, multiNumComplement);
            foreach (double[][] d in toBeTransformed){
                numC.Add(Transform(d));
            }
            mdata.ColumnNames = mdata.ColumnNames;
            mdata.Values.Set(expVals);
            mdata.SetAnnotationColumns(mdata.StringColumnNames, stringC, mdata.CategoryColumnNames, catC,
                new List<string>(ArrayUtils.Concat(mdata.NumericColumnNames,
                    ArrayUtils.SubList(mdata.MultiNumericColumnNames, multiNumCols))), numC,
                new List<string>(ArrayUtils.SubArray(mdata.MultiNumericColumnNames, multiNumComplement)), multiNumC);
        }
开发者ID:JurgenCox,项目名称:perseus-plugins,代码行数:99,代码来源:ExpandMultiNumeric.cs

示例5: GetIndicesOf

 public static int[] GetIndicesOf(IMatrixData data, string categoryName, HashSet<string> values)
 {
     int index = GetIndexOf(data, categoryName);
     List<int> result = new List<int>();
     for (int i = 0; i < data.RowCount; i++){
         string[] s = data.GetCategoryColumnEntryAt(index, i);
         foreach (string s1 in s){
             if (values.Contains(s1)){
                 result.Add(i);
                 break;
             }
         }
     }
     return result.ToArray();
 }
开发者ID:JurgenCox,项目名称:perseus-plugins,代码行数:15,代码来源:PerseusPluginUtils.cs


注:本文中的IMatrixData.GetCategoryColumnEntryAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。