#include <concordia/concordia.hpp> #include <concordia/concordia_search_result.hpp> #include <concordia/matched_pattern_fragment.hpp> #include <concordia/example.hpp> #include <concordia/tokenized_sentence.hpp> #include "config.hpp" #include <boost/shared_ptr.hpp> #include <boost/foreach.hpp> using namespace std; int main() { Concordia concordia("/tmp", 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<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(); }