Example #1
0
 CharacterVector cut(CharacterVector& x)
 {
   const char *const test_lines = x[0];
   vector<string> words;
   extractor.extract(test_lines, words, topN);
   return wrap(words);
 }
Example #2
0
 CharacterVector keys(vector<string>& test_lines)
 {
   vector<pair<string, double> > res;
   extractor.keys(test_lines, res, topN);
   //unsigned int it;
   CharacterVector m(res.size());
   CharacterVector atb(res.size());
   CharacterVector::iterator m_it = m.begin();
   CharacterVector::iterator atb_it = atb.begin();
   for (vector<pair<string, double> >::iterator it = res.begin(); it != res.end(); it++)
   {
     *m_it = (*it).first; m_it++;
     *atb_it = itos((*it).second); atb_it++;
   }
   m.attr("names") = atb;
   return wrap(m);
 }
Example #3
0
            bool run(const string& sentence, string& res) const
            {
                KeyInfo keyInfo;
                vector<string> words;
                if(!_keywordExtractor.extract(sentence, words, KEYWORD_TOP_N))
                {
                    LogError("[%s] extract failed.", sentence.c_str());
                    return false;
                }

                _findCityInfo(words, keyInfo.cityInfo);
                _findLocationInfo(words, keyInfo.locationInfo);
                _findTime(words,keyInfo.time);

                res << keyInfo;
                return true;
            }