<commit_before>#ifndef CP5_TEXTQUERY_H_
#define CP5_TEXTQUERY_H_

#include <string>
#include <memory>
#include <iostream>
#include <fstream>
#include <map>
#include <set>

#include "ex13_42_StrVec.h"

class QueryResult;
class TextQuery {
public:
    TextQuery(std::ifstream&);
    QueryResult query(const std::string&) const;

private:
    std::shared_ptr<StrVec> input;
    std::map<std::string, std::shared_ptr<std::set<size_t>>> result;
};

class QueryResult {
public:
    friend std::ostream& print(std::ostream&, const QueryResult&);

public:
    QueryResult(const std::string& s, std::shared_ptr<std::set<size_t>> set,
                std::shared_ptr<StrVec> v)
        : word(s), nos(set), input(v)
    {
    }

private:
    std::string word;
    std::shared_ptr<std::set<size_t>> nos;
    std::shared_ptr<StrVec> input;
};

std::ostream& print(std::ostream&, const QueryResult&);

#endif<commit_msg>Update ex13_42_TextQuery.h<commit_after>#ifndef CP5_ex12_27_30_h
#define CP5_ex12_27_30_h

#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <set>
#include <cstddef>
#include <memory>
#include "ex13_40.h"

using namespace std;

class QueryResult;

class TextQuery {
public:
    TextQuery(ifstream&);

    QueryResult query(const string&) const;

private:
    shared_ptr<StrVec> file;
    map<string, shared_ptr<set<size_t>>> wm;
};

class QueryResult {
friend ostream &print(ostream&, const QueryResult&);

public:
    QueryResult(string s, shared_ptr<set<size_t>> p, shared_ptr<StrVec> f):sought(s), lines(p), file(f) {}

private:
    string sought;
    shared_ptr<set<size_t>> lines;
    shared_ptr<StrVec> file;
};

ostream &print(ostream&, const QueryResult&);

#endif
{'fraction_non_alphanumeric': 0.1456140350877193, 'fraction_numerical': 0.016374269005847954, 'mean_word_length': 5.408239700374532, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 36, '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': '6853078', 'n_tokens_mistral': 646, 'n_tokens_neox': 631, 'n_words': 132}