Beispiel #1
0
 void Cut(const string& sentence, vector<string>& words, bool hmm = true) const {
   PreFilter pre_filter(symbols_, sentence);
   PreFilter::Range range;
   vector<Unicode> uwords;
   uwords.reserve(sentence.size());
   while (pre_filter.HasNext()) {
     range = pre_filter.Next();
     Cut(range.begin, range.end, uwords, hmm);
   }
   TransCode::Encode(uwords, words);
 }
Beispiel #2
0
 void Cut(const string& sentence, 
       vector<string>& words, 
       size_t max_word_len = MAX_WORD_LENGTH) const {
   PreFilter pre_filter(symbols_, sentence);
   PreFilter::Range range;
   vector<Unicode> uwords;
   uwords.reserve(sentence.size());
   while (pre_filter.HasNext()) {
     range = pre_filter.Next();
     Cut(range.begin, range.end, uwords, max_word_len);
   }
   TransCode::Encode(uwords, words);
 }
Beispiel #3
0
 void Cut(const string& sentence, 
       vector<Word>& words) const {
   PreFilter pre_filter(symbols_, sentence);
   PreFilter::Range range;
   vector<WordRange> wrs;
   wrs.reserve(sentence.size()/2);
   while (pre_filter.HasNext()) {
     range = pre_filter.Next();
     Cut(range.begin, range.end, wrs);
   }
   words.clear();
   words.reserve(wrs.size());
   GetWordsFromWordRanges(sentence, wrs, words);
 }