#include #include #include #include #include #include "config.hpp" #include #include using namespace std; int main() { Concordia concordia(EXAMPLES_DIR"/../tests/resources/concordia-config/concordia.cfg"); TokenizedSentence ts = concordia.addExample(Example("Alice has a cat", 56)); cout << "Added the following tokens: " << endl; BOOST_FOREACH(TokenAnnotation token, ts.getTokens()) { cout << "\"" << token.getValue() << "\"" << " at positions: [" << token.getStart() << "," << token.getEnd() << ")" << endl; } 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 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(); }