using System;
using System.IO;
namespace Frequency
{
class Frequency
{
	public static string[] File1; // array for first file
	public static string[] File2; // array for second file
	public static string[] find = new string[50];  // array for wordlist file
	static void Main()
	{
		Run(); // main method 
	}
	public static void Run()
	{
		FileOne(); //invoke all file mthods
		FileTwo();
		Find();
			for(int i=0; i<find.Length; i++) // main for loop counts until the lits ends
			{
				int count1 = 0; // int for freq in file 1
				int count2 = 0; // int for freq in file 2
				for(int j=0; j<File1.Length; j++) //sub for loop 1 counts until main's 
												// word is not iterated through it
				{
					if(find[i].Equals(File1[j]) == true)
					{
						count1++;
					}
				}
				for(int j=0; j<File2.Length; j++) //sub for loop 2 counts until main's 
												// word is not iterated through it
				{
					if(find[i].Equals(File2[j]) == true)
					{
						count2++;
					}
				}
				Console.WriteLine("{0,-10}	{1}	{2}", find[i], count1, count2);
				StreamWriter ss = new StreamWriter(@"F:\file2.txt", true);
				ss.WriteLine("{0,-20}	{1}	{2}", find[i], count1, count2);
				ss.Close();
			}
		
		Console.ReadLine();
	}
	static void FileOne() // get file one by stream reader, put it equal to string, get it to lower and split to array
	{
		char[] delims = new char[]{ ' ', '.', ',',';', '"', ':', '(', ')', '[', ']', '\'' };
		string path = @"F:\AgriAll.txt";
		StreamReader sr = new StreamReader(path);
		string str = sr.ReadToEnd();
		sr.Close();
		string str1 = str.ToLower();
		File1 = str1.Split(delims);
	}
	static void FileTwo() // get file two by stream reader, put it equal to string, get it to lower and split to array
	{
		char[] delims = new char[]{ ' ', '.', ',',';', '"', ':', '(', ')', '[', ']', '\'', '/', '?' };
		string path = @"F:\PWE-AllAgri.txt";
		StreamReader sr = new StreamReader(path);
		string str = sr.ReadToEnd();
		sr.Close();
		string str1 = str.ToLower();
		File2 = str1.Split(delims);
	}
	static void Find() //get list by stream reader, put it equal to string, get it to lower and split to array
	{
		string path = @"F:\Agriculture\EditedAgriKeywords.txt";
		StreamReader sw = new StreamReader(path);
		for(int i=0; i<find.Length; i++)
		{
			find[i] = sw.ReadLine();
		}
		sw.Close();
	}
}
}
