00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <iostream>
00022
00023 #include <boost/format.hpp>
00024 #include <boost/assign.hpp>
00025 #include <boost/bind.hpp>
00026
00027 #include "support/hptimer.hpp"
00028 #include "support/unicodehelpers.h"
00029
00030 #include "phrasehunter/corpus.h"
00031 #include "phrasehunter/token.h"
00032 #include "phrasehunter/searchengine.h"
00033
00034
00035 using namespace boost::assign;
00036 using boost::bind;
00037 using boost::format;
00038
00039 typedef std::list<std::string> StringList;
00040
00041 const StringList phrases =
00042 list_of
00043 ("d(er|ie|as) system\\w*");
00044
00045 void time_serge(PhraseHunter::SearchEngine* se, std::string phrase, int iterations = 10)
00046 {
00047 hptimer t;
00048 for(int i = 0; i < iterations; ++i) {
00049 se->searchPhrasalRegex(schma::UnicodePtr(new UnicodeString(phrase.c_str())));
00050 }
00051 unsigned long elapsed = t.elapsed();
00052
00053 std::cout << format("%|-30||%|5||%|10||%|10||")
00054 % phrase
00055 % iterations
00056 % elapsed
00057 % (elapsed / static_cast<double>(iterations))
00058 << std::endl;
00059 }
00060
00061 int main(int argc, char** argv)
00062 {
00063 PhraseHunter::CorpusManager corpus("corpora/testcorpus");
00064 PhraseHunter::SearchEngine *se = corpus.searchEngine();
00065
00066 std::cout << format("%|=30||%|=5||%|=10||%|=10||")
00067 % "phrase" % "i" % "t (ms)" % "1 (ms)" << std::endl;
00068
00069 for_each(phrases.begin(), phrases.end(),
00070 bind(time_serge, se, _1, 10));
00071 std::cout << std::endl;
00072
00073 return 0;
00074 }
00075
00076
00077
00078
00079