#ifndef CDEC_SENTENCES_H #define CDEC_SENTENCES_H #include #include #include #include "filelib.h" #include "tdict.h" #include "stringlib.h" typedef std::vector Sentence; inline std::ostream & operator<<(std::ostream &out,Sentence const& s) { return out< ss=SplitOnWhitespace(str); s.clear(); transform(ss.begin(),ss.end(),back_inserter(s),ToTD()); } inline Sentence StringToSentence(std::string const& str) { Sentence s; StringToSentence(str,s); return s; } inline std::istream& operator >> (std::istream &in,Sentence &s) { using namespace std; string str; if (getline(in,str)) { StringToSentence(str,s); } return in; } class Sentences : public std::vector { typedef std::vector VS; public: Sentences() { } Sentences(unsigned n,Sentence const& sentence) : VS(n,sentence) { } Sentences(unsigned n,std::string const& sentence) : VS(n,StringToSentence(sentence)) { } std::string filename; void Load(std::string file) { ReadFile r(file); Load(r.get(),file); } void Load(std::istream &in,std::string filen="-") { filename=filen; do { this->push_back(Sentence()); } while(in>>this->back()); this->pop_back(); } void Print(std::ostream &out,int headn=0) const { out << "[" << size()<< " sentences from "<size(); if (headn>0&&headn