#include <concordia/concordia.hpp>
#include <concordia/substring_occurence.hpp>
#include <concordia/example.hpp>

#include "config.hpp"

#include <boost/shared_ptr.hpp>
#include <vector>

using namespace std;

int main() {
    Concordia concordia(EXAMPLES_DIR"/../tests/resources/concordia-config/concordia.cfg");

    // adding sentences to index
    concordia.addExample(Example("Alice has a cat", 56));
    concordia.addExample(Example("Alice has a dog", 23));
    concordia.addExample(Example("New test product has a mistake", 321));
    concordia.addExample(Example("This is just testing and it has nothing to do with the above", 14));
    
    // generating index
    concordia.refreshSAfromRAM();
    
    // searching
    cout << "Searching for pattern: has a" << endl;
    vector<SubstringOccurence> result = concordia.simpleSearch("has a");

    // printing results
    for(vector<SubstringOccurence>::iterator it = result.begin();
        it != result.end(); ++it) {
        cout << "Found substring in sentence: " << it->getId() << " at offset: " << it->getOffset() << endl;
    }

    // clearing index
    concordia.clearIndex();
}