2015-05-04 20:40:44 +02:00
|
|
|
#include <concordia/concordia.hpp>
|
2015-08-07 12:54:57 +02:00
|
|
|
#include <concordia/matched_pattern_fragment.hpp>
|
2015-05-04 20:40:44 +02:00
|
|
|
#include <concordia/example.hpp>
|
|
|
|
|
|
|
|
#include "config.hpp"
|
|
|
|
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
int main() {
|
2015-10-16 22:14:11 +02:00
|
|
|
Concordia concordia("/tmp", EXAMPLES_DIR"/../tests/resources/concordia-config/concordia.cfg");
|
2015-05-04 20:40:44 +02:00
|
|
|
|
|
|
|
// 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;
|
2015-08-07 12:54:57 +02:00
|
|
|
vector<MatchedPatternFragment> result = concordia.simpleSearch("has a");
|
2015-05-04 20:40:44 +02:00
|
|
|
|
|
|
|
// printing results
|
2015-08-07 12:54:57 +02:00
|
|
|
for(vector<MatchedPatternFragment>::iterator it = result.begin();
|
2015-05-04 20:40:44 +02:00
|
|
|
it != result.end(); ++it) {
|
2015-08-07 12:54:57 +02:00
|
|
|
cout << "Found substring in sentence: " << it->getExampleId() << " at offset: " << it->getExampleOffset() << endl;
|
2015-05-04 20:40:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// clearing index
|
|
|
|
concordia.clearIndex();
|
|
|
|
}
|