たとえば、次のデータがあります。
YELLOW,SMALL,STRETCH,ADULT,T
YELLOW,SMALL,STRETCH,ADULT,T
YELLOW,SMALL,STRETCH,CHILD,F
YELLOW,SMALL,DIP,ADULT,F
YELLOW,SMALL,DIP,CHILD,F
YELLOW,LARGE,STRETCH,ADULT,T
YELLOW,LARGE,STRETCH,ADULT,T
YELLOW,LARGE,STRETCH,CHILD,F
YELLOW,LARGE,DIP,ADULT,F
YELLOW,LARGE,DIP,CHILD,F
PURPLE,SMALL,STRETCH,ADULT,T
PURPLE,SMALL,STRETCH,ADULT,T
PURPLE,SMALL,STRETCH,CHILD,F
PURPLE,SMALL,DIP,ADULT,F
PURPLE,SMALL,DIP,CHILD,F
PURPLE,LARGE,STRETCH,ADULT,T
PURPLE,LARGE,STRETCH,ADULT,T
PURPLE,LARGE,STRETCH,CHILD,F
PURPLE,LARGE,DIP,ADULT,F
PURPLE,LARGE,DIP,CHILD,F
次のデータ セットを生成する必要があります (上のデータの列が下のデータの数を生成することに注意してください)。5 つの列がある場合、4 つのデータ セットがあり、最初は 1 つの列、2 つ目は 2 つ、3 つ目は 3 つです。等々。最後の列は省略され、すべてのデータが結合される CLASS 列であり、数字は上記のデータでの出現回数です。
--------------------------------------------------
1 column
--------------------------------------------------
YELLOW T 4
SMALL T 4
STRETCH T 8
ADULT T 8
YELLOW F 6
SMALL F 6
STRETCH F 4
CHILD F 8
DIP F 8
ADULT F 4
LARGE T 4
LARGE F 6
PURPLE T 4
PURPLE F 6
--------------------------------------------------
2 columns
--------------------------------------------------
YELLOW SMALL T 2
YELLOW STRETCH T 4
YELLOW ADULT T 4
SMALL STRETCH T 4
SMALL ADULT T 4
STRETCH ADULT T 8
YELLOW SMALL F 3
YELLOW STRETCH F 2
YELLOW CHILD F 4
SMALL STRETCH F 2
SMALL CHILD F 4
STRETCH CHILD F 4
YELLOW DIP F 4
YELLOW ADULT F 2
SMALL DIP F 4
SMALL ADULT F 2
DIP ADULT F 4
DIP CHILD F 4
YELLOW LARGE T 2
LARGE STRETCH T 4
LARGE ADULT T 4
YELLOW LARGE F 3
LARGE STRETCH F 2
LARGE CHILD F 4
LARGE DIP F 4
LARGE ADULT F 2
PURPLE SMALL T 2
PURPLE STRETCH T 4
PURPLE ADULT T 4
PURPLE SMALL F 3
PURPLE STRETCH F 2
PURPLE CHILD F 4
PURPLE DIP F 4
PURPLE ADULT F 2
PURPLE LARGE T 2
PURPLE LARGE F 3
--------------------------------------------------
3 columns
--------------------------------------------------
YELLOW SMALL STRETCH T 2
YELLOW SMALL ADULT T 2
YELLOW STRETCH ADULT T 4
SMALL STRETCH ADULT T 4
YELLOW SMALL STRETCH F 1
YELLOW SMALL CHILD F 2
YELLOW STRETCH CHILD F 2
SMALL STRETCH CHILD F 2
YELLOW SMALL DIP F 2
YELLOW SMALL ADULT F 1
YELLOW DIP ADULT F 2
SMALL DIP ADULT F 2
YELLOW DIP CHILD F 2
SMALL DIP CHILD F 2
YELLOW LARGE STRETCH T 2
YELLOW LARGE ADULT T 2
LARGE STRETCH ADULT T 4
YELLOW LARGE STRETCH F 1
YELLOW LARGE CHILD F 2
LARGE STRETCH CHILD F 2
YELLOW LARGE DIP F 2
YELLOW LARGE ADULT F 1
LARGE DIP ADULT F 2
LARGE DIP CHILD F 2
PURPLE SMALL STRETCH T 2
PURPLE SMALL ADULT T 2
PURPLE STRETCH ADULT T 4
PURPLE SMALL STRETCH F 1
PURPLE SMALL CHILD F 2
PURPLE STRETCH CHILD F 2
PURPLE SMALL DIP F 2
PURPLE SMALL ADULT F 1
PURPLE DIP ADULT F 2
PURPLE DIP CHILD F 2
PURPLE LARGE STRETCH T 2
PURPLE LARGE ADULT T 2
PURPLE LARGE STRETCH F 1
PURPLE LARGE CHILD F 2
PURPLE LARGE DIP F 2
PURPLE LARGE ADULT F 1
--------------------------------------------------
4 columns
--------------------------------------------------
YELLOW SMALL STRETCH ADULT T 2
YELLOW SMALL STRETCH CHILD F 1
YELLOW SMALL DIP ADULT F 1
YELLOW SMALL DIP CHILD F 1
YELLOW LARGE STRETCH ADULT T 2
YELLOW LARGE STRETCH CHILD F 1
YELLOW LARGE DIP ADULT F 1
YELLOW LARGE DIP CHILD F 1
PURPLE SMALL STRETCH ADULT T 2
PURPLE SMALL STRETCH CHILD F 1
PURPLE SMALL DIP ADULT F 1
PURPLE SMALL DIP CHILD F 1
PURPLE LARGE STRETCH ADULT T 2
PURPLE LARGE STRETCH CHILD F 1
PURPLE LARGE DIP ADULT F 1
PURPLE LARGE DIP CHILD F 1
したがって、50 列もあれば、80 列以上になることもあります。
複雑なのは、単語の代わりに 0 と 1 が存在する可能性があり、同じ列と一致する必要があることです。
あなたが質問を得たことを願っています。
最初の列を生成するために次のコードを作成しました。主な問題は、残りの列です。
for (int i = 0; i < lsClasses.Count; i++)
{
for (int j = 0; j < lsUniqueOps.Count; j++)
{
int count = FindInOrignalList(orignalList, lsClasses[i], lsUniqueOps[j]);
if (count != 0)
{
List<string> checkedItem = new List<string>();
checkedItem.Add(lsUniqueOps[j][0]);
checkedItem.Add(lsUniqueOps[j][1]);
checkedItem.Add(lsClasses[i]);
checkedItem.Add(count.ToString());
lsFirstItemSet.Add(checkedItem);
}
}
}
--------------------------------------------------
private static int FindInOrignalList(List<List<string>> orignalList, string lsClass, List<string> lsUniqueOp)
{
List<List<string>> tmpList = new List<List<string>>();
int count = 0;
for (int i = 0; i < orignalList.Count; i++)
{
for (int j = 0; j < orignalList[i].Count - 1; j++)
{
if (orignalList[i][j] + "," + orignalList[i][orignalList[i].Count - 1] == lsUniqueOp[0] + "," + lsClass)
count++;
}
}
return count;
}