<commit_before>#include "scientistservice.h"
#include <algorithm>
#include <iostream>

using namespace std;

struct ScientitComparisonNameForward {
    bool operator() (Scientist i, Scientist j) {return (i.getName()<j.getName());}
};

bool ScientitComparisonYearOfBirthForward (Scientist i, Scientist j)
{
    return (i.getYearOfBirth()<j.getYearOfBirth());
}

bool ScientitComparisonYearOfDeathForward (Scientist i, Scientist j)
{
    return (i.getYearOfDeath()<j.getYearOfDeath());
}
bool ScientitComparisonAgeForward (Scientist i, Scientist j)
{
    return (i.getAge()<j.getAge());
}
struct ScientitComparisonGenderForward {
    bool operator() (Scientist i, Scientist j) {return (i.getGender()<j.getGender());}
};

ScientistService::ScientistService()
{

}
 vector<Scientist> ScientistService::getScientists(string sort)
{
    vector<Scientist> performers;

    Scientist p("<NAME>","f",1640,1700); //60 ara
    Scientist p2("madona","m",1953,0 ); //46 ara
    Scientist p3("ALi","f",2130,2200); //70 ara

    performers.push_back(p);
    performers.push_back(p2);
    performers.push_back(p3);

    //TODO: logic
    //sort by name

    if (sort == "name" || sort == "Name")
    {
        ScientitComparisonNameForward cmp;
        std::sort(performers.begin(), performers.end(), cmp);
    }
    else if (sort == "birth" || sort == "Birth")
    {
        std::sort(performers.begin(), performers.end(), ScientitComparisonYearOfBirthForward);
    }
    else if (sort == "death" || sort == "Death")
    {
        std::sort(performers.begin(), performers.end(), ScientitComparisonYearOfDeathForward);
    }
    else if (sort == "age" || sort == "Age")
    {
        std::sort(performers.begin(), performers.end(), ScientitComparisonAgeForward);
    }
    else
    {
        //default is to sort by name
        ScientitComparisonNameForward cmp;
        std::sort(performers.begin(), performers.end(), cmp);
    }

    return performers;
}

vector<Scientist> ScientistService::searchScientists(string searchData){
    vector<Scientist> performers;

    vector<Scientist> foundScientists;

    Scientist p("<NAME>","f",1640,1700); //60 ara
    Scientist p2("madona","m",1953,1999 ); //46 ara
    Scientist p3("ALi","f",2130,2200); //70 ara
    Scientist p4("Anna","f",1640,1700); //60 ara
    Scientist p5("Arnaldur","m",1953,1999 ); //46 ara

    performers.push_back(p);
    performers.push_back(p2);
    performers.push_back(p3);
    performers.push_back(p4);
    performers.push_back(p5);



    for(unsigned long i = 0; i < performers.size(); i++){
        string name = performers[i].getName();
        if(name.substr(0,searchData.size()) == searchData)
        {
            //If we find the scientist then we...
            foundScientists.push_back(performers[i]);

        }
    }
    return foundScientists; //remeber to change
}


void ScientistService::addScientist(Scientist scientist)
{
    bool isin = ifExist(scientist.getName());

    if (isin == false)
    {
         _scientists.push_back(scientist);
    }
   // _scientists.push_back(scientist);
}

/*
Scientist ScientistService::getScientist(int index) const
{
    //return _scientists[index];
}
*/


int ScientistService::getSize() const
{<commit_msg>searchScientists modified<commit_after>#include "scientistservice.h"
#include <algorithm>
#include <iostream>

using namespace std;

struct ScientitComparisonNameForward {
    bool operator() (Scientist i, Scientist j) {return (i.getName()<j.getName());}
};

bool ScientitComparisonYearOfBirthForward (Scientist i, Scientist j)
{
    return (i.getYearOfBirth()<j.getYearOfBirth());
}

bool ScientitComparisonYearOfDeathForward (Scientist i, Scientist j)
{
    return (i.getYearOfDeath()<j.getYearOfDeath());
}
bool ScientitComparisonAgeForward (Scientist i, Scientist j)
{
    return (i.getAge()<j.getAge());
}
struct ScientitComparisonGenderForward {
    bool operator() (Scientist i, Scientist j) {return (i.getGender()<j.getGender());}
};

ScientistService::ScientistService()
{

}
 vector<Scientist> ScientistService::getScientists(string sort)
{
    vector<Scientist> performers;

    Scientist p("<NAME>","f",1640,1700); //60 ara
    Scientist p2("madona","m",1953,0 ); //46 ara
    Scientist p3("ALi","f",2130,2200); //70 ara

    performers.push_back(p);
    performers.push_back(p2);
    performers.push_back(p3);

    //TODO: logic
    //sort by name

    if (sort == "name" || sort == "Name")
    {
        ScientitComparisonNameForward cmp;
        std::sort(performers.begin(), performers.end(), cmp);
    }
    else if (sort == "birth" || sort == "Birth")
    {
        std::sort(performers.begin(), performers.end(), ScientitComparisonYearOfBirthForward);
    }
    else if (sort == "death" || sort == "Death")
    {
        std::sort(performers.begin(), performers.end(), ScientitComparisonYearOfDeathForward);
    }
    else if (sort == "age" || sort == "Age")
    {
        std::sort(performers.begin(), performers.end(), ScientitComparisonAgeForward);
    }
    else
    {
        //default is to sort by name
        ScientitComparisonNameForward cmp;
        std::sort(performers.begin(), performers.end(), cmp);
    }

    return performers;
}

vector<Scientist> ScientistService::searchScientists(string searchData)
{
    vector<Scientist> foundScientists;

    for(unsigned long i = 0; i < _scientists.size(); i++){
        string name = _scientists[i].getName();
        if(name.substr(0,searchData.size()) == searchData)
        {
            //If we find the scientist then we...
            foundScientists.push_back(_scientists[i]);

        }
    }
    return foundScientists; //remeber to change
}


void ScientistService::addScientist(Scientist scientist)
{
    bool isin = ifExist(scientist.getName());

    if (isin == false)
    {
         _scientists.push_back(scientist);
    }
   // _scientists.push_back(scientist);
}

/*
Scientist ScientistService::getScientist(int index) const
{
    //return _scientists[index];
}
*/


int ScientistService::getSize() const
{
{'fraction_non_alphanumeric': 0.14887966804979252, 'fraction_numerical': 0.02058091286307054, 'mean_word_length': 3.6353846153846154, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3265811', 'n_tokens_mistral': 2127, 'n_tokens_neox': 1933, 'n_words': 388}