Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Space.cpp 729 B
//
// Created by tomas on 3/23/20.
//

#include "Space.h"

using namespace std;

Space::Space(map<string, InvertedIndex> terms)
        : terms(move(terms)) {}


const InvertedIndex &Space::operator[](const string &key) const {
    return terms.at(key);
}

InvertedIndex &Space::getInvertedIndexByKey(const string &key) {
    return terms.at(key);
}

const map<string, double> Space::getTermsAndWeightsByID(Terms & collection, int document_id) {
    map<string, double> terms;
    vector<string> dummy = collection.getTermsByDocumentID(document_id);

    for (string term : dummy) {
        InvertedIndex tmp = getInvertedIndexByKey(term);
        terms[term] = tmp.getDocumentWeightByID(document_id);
    }

    return terms;
}