本文整理汇总了C#中IMatrixData.GetCategoryColumnValuesAt方法的典型用法代码示例。如果您正苦于以下问题:C# IMatrixData.GetCategoryColumnValuesAt方法的具体用法?C# IMatrixData.GetCategoryColumnValuesAt怎么用?C# IMatrixData.GetCategoryColumnValuesAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMatrixData
的用法示例。
在下文中一共展示了IMatrixData.GetCategoryColumnValuesAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetParameters
public Parameters GetParameters(IMatrixData mdata, ref string errorString)
{
Parameters[] subParams = new Parameters[mdata.CategoryColumnCount];
for (int i = 0; i < mdata.CategoryColumnCount; i++){
string[] values = mdata.GetCategoryColumnValuesAt(i);
int[] sel = values.Length == 1 ? new[]{0} : new int[0];
subParams[i] =
new Parameters(new Parameter[]{
new MultiChoiceParam("Values", sel){
Values = values,
Help = "The value that should be present to discard/keep the corresponding row."
}
});
}
return
new Parameters(new SingleChoiceWithSubParams("Column"){
Values = mdata.CategoryColumnNames,
SubParams = subParams,
Help = "The categorical column that the filtering should be based on.",
ParamNameWidth = 50,
TotalWidth = 731
}, new SingleChoiceParam("Mode"){
Values = new[]{"Remove matching rows", "Keep matching rows"},
Help =
"If 'Remove matching rows' is selected, rows having the values specified above will be removed while " +
"all other rows will be kept. If 'Keep matching rows' is selected, the opposite will happen."
}, PerseusPluginUtils.GetFilterModeParam(true));
}
示例2: 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());
}