outlook temperature Humidity Windy PlayTennis

    sunny      hot        high     false   N

sunny hot high true N
overcast hot high false P
rain mild high false P
rain cool normal false P

I found out unique elements from file and their occurence ( ignored the elements whose occurence was less than 1(taking 1 just for e.g, i need to take this from user))

suny : 2
rain: 2
hot :3
high:4
false:4
n:2
p:3

Now i want output as( from the first output, it should loop with every other element to make a set of two frequent set)
element:occurence

sunny,hot:2
sunny,high:2
sunny,false:1
sunny,n:2
sunny,p:0
rain,hot:0
rain,high:1
rain,false:2
rain,n:0
rain,p:2
hot,high:2
hot,false:1
hot,n:2
hot,p:0
and so on..

var occurences = File.ReadAllLines(file).Skip(1) // skip titles line

    .SelectMany(l => l.Split(new []{' '}, StringSplitOptions.RemoveEmptyEntries))


.GroupBy(w => w)
.ToDictionary(g => g.Key, g => g.Count());

int sunnyOccurences = occurences["sunny"];

foreach(var pair in occurences)

    label1.Text += String.Format("{0}: {1}\n", pair.Key, pair.Value);

I implemented this to find the 1st frequent set.
for 2nd one. what should i do ??
I also need to find the third set.

I am new to c#. Please help me.

Rather than trying to work with strings, place it into a data structure. It will be much easier to work with.

eg.

public class Weather
{
    public String Outlook
    {get;set;}

    public String Temperature
    {get;set;}

    public String Humidity
    {get;set;}

    public String Windy
    {get;set;}

    public Boolean PlayTennis
    {get;set;}
}

Then you can have a list of Weather and do lookup on that list.

Additionally, rather than using Strings you could use ENUM.

commented: The way to go! +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.