public static void Main(string[] args)
        {
            //Object to Hold Task Parameters
            TaskDimensions task = new TaskDimensions();

            //Dictionary that contains a list of top ten jobs compared with other jobs for each user
            Dictionary<int, List<TopJobData>> finalList = new Dictionary<int, List<TopJobData>>();

            //User number to start proccessing
            int user_number = 1;

            IFileSystemSvc svc = new FileSystemSvcImpl();

            //Method call to get the number of jobs and users from the file Y
            svc.detectSizeOfJobsColumns(task, Directory.GetCurrentDirectory()+"/files/Y1.txt");

            //Method call to get the number of features from the file X, and allocating the X matrix
            double[,] X = svc.getNumberOfFeaturesX(Directory.GetCurrentDirectory() + "/files/X1.txt", task);
            svc.readFeaturesX(X, Directory.GetCurrentDirectory() + "/files/X1.txt", task);

            //Method call to get the jobs names
            String[] job_list = svc.readJobNames(Directory.GetCurrentDirectory() + "/files/job_names1.txt", task);

            //Creating a variable to write in a File the job recommendations and comparisons
            StreamWriter writeText = svc.getResultStreamWriter();

            while (user_number <= task.num_users_init)
            {
                // Movie rating file for a user
                double[,] my_ratings = new double[task.num_jobs_init, 1];

                //Now we read R and Y from theirs files (-1 because I will remove the chosen user from the matrixes)
                double[,] Y = svc.readTrainingY(Directory.GetCurrentDirectory() + "/files/Y1.txt", task, my_ratings, user_number);
                double[,] R = svc.readTrainingR(Directory.GetCurrentDirectory() + "/files/R1.txt", task, user_number);

                //Creating a MatLab reference to execute the recommended job script
                IMatlabSvc matSvc = new MatlabSvcImpl();
                object[] res = matSvc.executeFilter(task, job_list, Directory.GetCurrentDirectory()+ "/files", my_ratings, Y, R, X, user_number);

                //Each time creates a  to be used to write the recommended jobs in a file
                List<TopJobData> mylist = svc.writeValuesToFile(writeText, res, job_list, user_number);

                //adding the list at the Dictionary for each user
                finalList.Add(user_number, mylist);

                user_number++;
            }

            writeText.Close();

            //creating a instance of DataResult to be used to write the averages in a file
            DataResult avgs = new DataResult(finalList, 10);
            avgs.calculateAverages();

            Console.WriteLine("DONE");

            // Wait until fisnih
            Console.ReadLine();
        }
        public static void Main(string[] args)
        {
            //Object to Hold Task Parameters
            TaskDimensions task = new TaskDimensions();

            //Dictionary that contains a list of top ten jobs compared with other jobs for each user
            Dictionary<int, List<TopJobData>> finalList = new Dictionary<int, List<TopJobData>>();

            //User number to start proccessing
            int user_number = 1;

            //Load File System Service
            IFileSystemSvc svc = new FileSystemSvcImpl();

            //Method call to get the number of jobs and users from the file Y
            svc.detectSizeOfJobsColumns(task, Directory.GetCurrentDirectory()+"/files/Y.txt");

            //Method call to get the number of features from the file X, and allocating the X matrix
            double[,] X = svc.getNumberOfFeaturesX(Directory.GetCurrentDirectory() + "/files/X.txt", task);
            svc.readFeaturesX(X, Directory.GetCurrentDirectory() + "/files/X.txt", task);

            //Method call to get the jobs names
            String[] job_list = svc.readJobNames(Directory.GetCurrentDirectory() + "/files/job_names.txt", task);

            //method that return the users profile
            UserProfile[] users_profile = svc.readUserProfile(Directory.GetCurrentDirectory() + "/files/user_table.txt", task);

            //Creating a variable to write in a File the job recommendations and comparisons
            //Load File Writer
            StreamWriter writeTextResult = svc.getResultStreamWriter();
            StreamWriter writeTextAverages = svc.getAverageStreamWriter();

            double total_avg_system = 0;
            double total_user_inaccuracy = 0;

            while (user_number <= task.num_users_init)
            {
                // Movie rating file for a user
                double[,] my_ratings = new double[task.num_jobs_init, 1];

                //Now we read R and Y from theirs files (-1 because I will remove the chosen user from the matrixes)
                double[,] Y = svc.readTrainingY(Directory.GetCurrentDirectory() + "/files/Y.txt", task, my_ratings, user_number);
                double[,] R = svc.readTrainingR(Directory.GetCurrentDirectory() + "/files/R.txt", task, user_number);

                //Creating a MatLab reference to execute the recommended job script
                IMatlabSvc matSvc = new MatlabSvcImpl();
                object[] res = matSvc.executeFilter(task, job_list, Directory.GetCurrentDirectory()+ "/files", my_ratings, Y, R, X, user_number);

                //Each time creates a  to be used to write the recommended jobs in a file
                List<TopJobData> mylist = svc.writeValuesToFile(writeTextResult, res, job_list, user_number);

                //Calculate Averages for Jobs for a User
                DataResult avgs = new DataResult(mylist, 10, users_profile[user_number - 1]);
                avgs.AverageForEachJob();
                svc.writeAveragesToFile(avgs, writeTextAverages, users_profile[user_number - 1]);

                total_avg_system += avgs.Percentage_total_avg;
                total_user_inaccuracy += avgs.Self_inaccuracy;
                //adding the list at the Dictionary for each user

                user_number++;
            }

            total_avg_system /= task.num_users_init;
            writeTextAverages.WriteLine("AVGS TOTAL\t" + total_avg_system);
            total_user_inaccuracy /= task.num_users_init;
            writeTextAverages.WriteLine("COMMUNITY INACCURACY\t" + total_user_inaccuracy);

            writeTextResult.Close();
            writeTextAverages.Close();

            //creating a instance of DataResult to be used to write the averages in a file
            Console.WriteLine("DONE");

            //Wait until fisnih
            Console.ReadLine();
        }
        public static void Main(string[] args)
        {
            //Object to Hold Task Parameters
            TaskDimensions task = new TaskDimensions();

            //User number to start proccessing
            int user_number = 1;

            //Load File System Service
            IFileSystemSvc svc = new FileSystemSvcImpl();

            //Method call to get the number of jobs and users from the file Y
            svc.detectSizeOfJobsColumns(task, Directory.GetCurrentDirectory()+"/files/new_Y_53.txt");

            //Method call to get the number of features from the file X, and allocating the X matrix
            double[,] X = svc.getNumberOfFeaturesX(Directory.GetCurrentDirectory() + "/files/X.txt", task);
            svc.readFeaturesX(X, Directory.GetCurrentDirectory() + "/files/X.txt", task);

            //Method call to get the jobs names
            String[] job_list = svc.readJobNames(Directory.GetCurrentDirectory() + "/files/expressions.txt", task);

            //method that return the users profile
            UserProfile[] users_profile = svc.readUserProfile(Directory.GetCurrentDirectory() + "/files/new_user_table_53.txt", task);

            //Creating a variable to write in a File the job recommendations and comparisons
            //Load File Writer
            StreamWriter writeTextResult = svc.getResultStreamWriter();
            StreamWriter writeTextAverages = svc.getAverageStreamWriter();
            StreamWriter writeText = svc.getIdandAvgStreamWriter();
            StreamWriter writeTextDiff = svc.getDifficultyStreamWriter();

            double[] users_calculated_raitings = new double[task.num_users_init];

            double total_rating_avg_system = 0;
            double total_similarity_avg_system = 0;
            double total_inaccuracy_system = 0;

            while (user_number <= task.num_users_init)
            {
                // job rating file for a user
                double[,] my_ratings = new double[task.num_jobs_init, 1];

                //Now we read R and Y from theirs files (-1 because I will remove the chosen user from the matrixes)
                double[,] Y = svc.readTrainingY(Directory.GetCurrentDirectory() + "/files/new_Y_53.txt", task, my_ratings, user_number);
                double[,] R = svc.readTrainingR(Directory.GetCurrentDirectory() + "/files/new_R_53.txt", task, user_number);

                //Creating a MatLab reference to execute the recommended job script
                IMatlabSvc matSvc = new MatlabSvcImpl();
                object[] res = matSvc.executeFilter(task, job_list, Directory.GetCurrentDirectory()+ "/files", my_ratings, Y, R, X, user_number);

                //Each time creates a  to be used to write the recommended jobs in a file
                List<TopJobData> mylist = svc.writeValuesToFile(writeTextResult, res, job_list, user_number, X);

                //Calculate Averages for Jobs for a User
                DataResult avgs = new DataResult(mylist, mylist.Count, users_profile[user_number - 1]);
                avgs.AverageForEachJob();
                svc.writeAveragesToFile(avgs, writeTextAverages, users_profile[user_number - 1]);

                total_rating_avg_system += avgs.Rating_total_avg;
                total_similarity_avg_system += avgs.Percentage_total_avg;
                total_inaccuracy_system += avgs.Self_inaccuracy;
                //adding the list at the Dictionary for each user

                //ID and AVGs file
                writeText.WriteLine(users_profile[user_number - 1].UserID + "\t" + avgs.Rating_total_avg);

                users_calculated_raitings[user_number - 1] = avgs.Rating_total_avg;

                //writing in the difficulty file
                svc.writeDifficultyToFile(writeTextDiff, avgs);

                //used to inC:\Users\larissaf\Desktop\FinaleVersionCrowd\recommenderSystems\Driver.cssert recommended jobs for a user in the database
                IElasticSvc es = new ElasticSvcImpl();
                es.insertRecommenderJob(avgs);

                user_number++;

            }

            total_rating_avg_system /= task.num_users_init;
            total_similarity_avg_system /= task.num_users_init;
            total_inaccuracy_system /= task.num_users_init;
            //writing some more global information
            svc.writeGlobalAveragesInformation(total_rating_avg_system, total_similarity_avg_system, total_inaccuracy_system,
                 task, writeTextAverages, users_profile, users_calculated_raitings);

            //closing the three files
            writeText.Close();
            writeTextResult.Close();
            writeTextAverages.Close();
            writeTextDiff.Close();

            /*
             * Used to insert rating for task performed by workers. (User interface need to be built)
             *
            double[,] full_Y = svc.readFullY(Directory.GetCurrentDirectory() + "/files/Y.txt", task);
            IElasticSvc e = new ElasticSvcImpl();
            e.InsertRatings(job_list, users_profile, full_Y);
            */

            Console.WriteLine("DONE");

            //Wait until fisnih
            Console.ReadLine();
        }
 //Writes in a file the calculated averages for each job for each user in FinalList, and also the average of the
 //percentage averages for each jobs (the total average for the System)
 public void calculateAverages()
 {
     double totalAverageforSystem = 0;
     int i;
     IFileSystemSvc svc = new FileSystemSvcImpl();
     StreamWriter writeText = svc.getAverageStreamWriter();
     for (i = 0; i < this.finalList.Count; i++)
     {
         this.list = this.finalList.Values.ElementAt(i);
         this.AverageForEachJob();
         svc.writeAveragesToFile(this, writeText, i);
         totalAverageforSystem += this.Percentage_total_avg;
     }
     writeText.WriteLine("TOTAL AVERAGE FOR THE SYSTEM " + totalAverageforSystem/i);
     writeText.Close();
 }
        public static void Main(string[] args)
        {
            //JOBS LIST and X is working but the order is different
            JobSvcImpl j = new JobSvcImpl();
            String[] job_list = j.selectExpressionNames(); //job_names
            double[] X = j.selectExpressionDifficulty(); //X
            double[,] new_X = new double[X.Length, 1];
            for (int i = 0; i < X.Length; i++)
            {
                new_X[i, 0] = X[i];
            }

            //User Profile (just the user ID, I still need the user self rating)
            RecruiteeSvcImpl r = new RecruiteeSvcImpl();
            String[] recruitee_names = r.selectRecruiteeNames();
            double[] recruitee_skill = r.selectRecruiteeSkills();
            UserProfile[] users_profile = new UserProfile[recruitee_skill.Length];
            for (int i = 0; i < recruitee_skill.Length; i++)
            {
                users_profile[i] = new UserProfile("",0);
                users_profile[i].UserID = recruitee_names[i];
                users_profile[i].UserRating = recruitee_skill[i];
            }
            //new_Y
            IElasticSvc es = new ElasticSvcImpl();
            double[,] Y = es.SelectRatings(job_list, users_profile);

            ///////// WRITING VARIABLES IN FILE ////////////
            FromWebToFile file = new FromWebToFile();
            file.writeFiles(job_list,new_X,users_profile,Y);

            //Object to Hold Task Parameters
            TaskDimensions task = new TaskDimensions();
            task.num_features = new_X.GetLength(1); //1 is the number of columns
            task.num_jobs_init = job_list.Length;
            task.num_users_init = recruitee_names.Length;

            //User number to start proccessing
            int user_number = 1;

            //Load File System Service
            IFileSystemSvc svc = new FileSystemSvcImpl();

            //Creating a variable to write in a File the job recommendations and comparisons
            //Load File Writer
            StreamWriter writeTextResult = svc.getResultStreamWriter();
            StreamWriter writeTextAverages = svc.getAverageStreamWriter();
            StreamWriter writeText = svc.getIdandAvgStreamWriter();
            StreamWriter writeTextDiff = svc.getDifficultyStreamWriter();

            double[] users_calculated_raitings = new double[task.num_users_init];

            double total_rating_avg_system = 0;
            double total_similarity_avg_system = 0;
            double total_inaccuracy_system = 0;

            while (user_number <= task.num_users_init)
            {
                double[,] my_ratings = new double[task.num_jobs_init, 1];
                double[,] new_Y = new double[task.num_jobs_init, task.num_users_init - 1];
                double[,] R = new double[task.num_jobs_init, task.num_users_init - 1];

                for (int i = 0; i < job_list.Length; i++)
                {
                    int k = 0;
                    for (int n = 0; n < users_profile.Length; n++)
                    {
                        if (n != (user_number - 1))
                        {
                            new_Y[i, k] = Y[i, n];
                            if (Y[i, n] != 0)
                                R[i, k] = 1;
                            else
                                R[i, k] = 0;
                            k++;
                        }
                        else
                            my_ratings[i, 0] = Y[i, n];
                    }
                }

                //Creating a MatLab reference to execute the recommended job script
                IMatlabSvc matSvc = new MatlabSvcImpl();
                object[] res = matSvc.executeFilter(task, job_list, Directory.GetCurrentDirectory()+ "/files", my_ratings, new_Y, R, new_X, user_number);

                //Each time creates a  to be used to write the recommended jobs in a file
                List<TopJobData> mylist = svc.writeValuesToFile(writeTextResult, res, job_list, user_number, new_X);

                //Calculate Averages for Jobs for a User
                DataResult avgs = new DataResult(mylist, mylist.Count, users_profile[user_number - 1]);
                avgs.AverageForEachJob();
                svc.writeAveragesToFile(avgs, writeTextAverages, users_profile[user_number - 1]);

                total_rating_avg_system += avgs.Rating_total_avg;
                total_similarity_avg_system += avgs.Percentage_total_avg;
                total_inaccuracy_system += avgs.Self_inaccuracy;
                //adding the list at the Dictionary for each user

                //ID and AVGs file
                writeText.WriteLine(users_profile[user_number - 1].UserID + "\t" + avgs.Rating_total_avg);

                users_calculated_raitings[user_number - 1] = avgs.Rating_total_avg;

                //writing in the difficulty file
                svc.writeDifficultyToFile(writeTextDiff, avgs);

                //used to insert recommended jobs for a user in the database
                es.insertRecommenderJob(avgs);

                user_number++;

            }

            total_rating_avg_system /= task.num_users_init;
            total_similarity_avg_system /= task.num_users_init;
            total_inaccuracy_system /= task.num_users_init;
            //writing some more global information
            svc.writeGlobalAveragesInformation(total_rating_avg_system, total_similarity_avg_system, total_inaccuracy_system,
                task, writeTextAverages, users_profile, users_calculated_raitings);

            //closing the three files
            writeText.Close();
            writeTextResult.Close();
            writeTextAverages.Close();
            writeTextDiff.Close();

            /*
             * Used to insert rating for task performed by workers. (User interface need to be built)
             *
            double[,] full_Y = svc.readFullY(Directory.GetCurrentDirectory() + "/files/Y.txt", task);
            IElasticSvc e = new ElasticSvcImpl();
            e.InsertRatings(job_list, users_profile, full_Y);
            */

            Console.WriteLine("DONE");

            //Wait until fisnih
            Console.ReadLine();
        }