49 lines
1.9 KiB
C++
49 lines
1.9 KiB
C++
|
#include <concordia/concordia.hpp>
|
||
|
#include <concordia/concordia_search_result.hpp>
|
||
|
#include <concordia/matched_pattern_fragment.hpp>
|
||
|
#include <concordia/example.hpp>
|
||
|
|
||
|
#include "config.hpp"
|
||
|
|
||
|
#include <boost/shared_ptr.hpp>
|
||
|
#include <boost/foreach.hpp>
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
int main() {
|
||
|
Concordia concordia(EXAMPLES_DIR"/../tests/resources/concordia-config/concordia.cfg");
|
||
|
|
||
|
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));
|
||
|
|
||
|
concordia.refreshSAfromRAM();
|
||
|
|
||
|
cout << "Searching for pattern: Our new test product has nothing to do with computers" << endl;
|
||
|
boost::shared_ptr<ConcordiaSearchResult> result =
|
||
|
concordia.concordiaSearch("Our new test product has nothing to do with computers");
|
||
|
|
||
|
cout << "Printing all matched fragments:" << endl;
|
||
|
BOOST_FOREACH(MatchedPatternFragment fragment, result->getFragments()) {
|
||
|
cout << "Matched pattern fragment found. Pattern fragment: ["
|
||
|
<< fragment.getStart() << "," << fragment.getEnd() << "]"
|
||
|
<< " in sentence " << fragment.getExampleId()
|
||
|
<< ", at offset: " << fragment.getExampleOffset() << endl;
|
||
|
}
|
||
|
|
||
|
|
||
|
cout << "Best overlay:" << endl;
|
||
|
BOOST_FOREACH(MatchedPatternFragment fragment, result->getBestOverlay()) {
|
||
|
cout << "\tPattern fragment: [" << fragment.getStart()
|
||
|
<< "," << fragment.getEnd() << "]"
|
||
|
<< " in sentence " << fragment.getExampleId()
|
||
|
<< ", at offset: " << fragment.getExampleOffset() << endl;
|
||
|
}
|
||
|
|
||
|
cout << "Best overlay score: " << result->getBestOverlayScore() << endl;
|
||
|
|
||
|
// clearing index
|
||
|
concordia.clearIndex();
|
||
|
}
|