diff options
Diffstat (limited to 'contrib/synlm/hhmm/rvtl')
28 files changed, 186 insertions, 186 deletions
diff --git a/contrib/synlm/hhmm/rvtl/include/nl-archetypeset.h b/contrib/synlm/hhmm/rvtl/include/nl-archetypeset.h index 914e85e92..342f10777 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-archetypeset.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-archetypeset.h @@ -65,7 +65,7 @@ class Numbered : public T { friend String& operator<< ( String& str, const Numbered<SD1,I,SD2,T,SD3>& rv ) { return str<<SD1<<rv.i<<SD2<<rv.getT()<<SD3; } friend pair<StringInput,Numbered<SD1,I,SD2,T,SD3>*> operator>> ( StringInput ps, Numbered<SD1,I,SD2,T,SD3>& rv ) { return pair<StringInput,Numbered<SD1,I,SD2,T,SD3>*>(ps,&rv); } friend StringInput operator>> ( pair<StringInput,Numbered<SD1,I,SD2,T,SD3>*> delimbuff, const char* psPostDelim ) { - return ( (SD3[0]=='\0') ? delimbuff.first>>SD1>>delimbuff.second->i>>SD2>>delimbuff.second->setT()>>psPostDelim + return ( (SD3[0]=='\0') ? delimbuff.first>>SD1>>delimbuff.second->i>>SD2>>delimbuff.second->setT()>>psPostDelim : delimbuff.first>>SD1>>delimbuff.second->i>>SD2>>delimbuff.second->setT()>>SD3>>psPostDelim ); } }; @@ -106,7 +106,7 @@ template<class V> pair<typename V::ElementType,int> ArchetypeSet<V>::getDistanceOfNearest ( const V& v ) const { //const Scored<typename V::ElementType,pair<int,SafePtr<const V> > > sipvDummy ( DBL_MAX ); //MinHeap<Scored<typename V::ElementType,pair<int,SafePtr<const V> > > > hsiv ( MapType::size()+1, sipvDummy ); - MinHeap<Scored<typename V::ElementType,pair<int,SafePtr<const NV> > > >& hsiv = + MinHeap<Scored<typename V::ElementType,pair<int,SafePtr<const NV> > > >& hsiv = const_cast<MinHeap<Scored<typename V::ElementType,pair<int,SafePtr<const NV> > > >&> ( hsivCalc ); hsiv.clear(); @@ -120,7 +120,7 @@ pair<typename V::ElementType,int> ArchetypeSet<V>::getDistanceOfNearest ( const typename V::ElementType d = v.getMarginalDistance ( hsiv.get(iNext).first, hsiv.get(iNext).second.getRef() ); hsiv.set(iNext).setScore() = d; //hsiv.set(iNext).setScore() = v.getMarginalDistance ( hsiv.getMin().first, iUpper->second.second ); - ////int j = + ////int j = hsiv.fixDecr(iNext); ////cerr<<" adding ln"<<&hsiv.get(j).second.getRef()<<" marg-dist="<<d<<" new-score="<<double(hsiv.get(j).getScore())<<" new-pos="<<j<<"\n"; iNext++; @@ -140,7 +140,7 @@ pair<typename V::ElementType,int> ArchetypeSet<V>::getDistanceOfNearest ( const typename V::ElementType d = v.getMarginalDistance ( ++hsiv.setMin().first, hsiv.getMin().second.getRef() ); hsiv.setMin().setScore() += d; ////cerr<<" matching ln"<<&hsiv.getMin().second.getRef()<<" i="<<hsiv.setMin().first<<" marg-dist="<<d<<" new-score="<<hsiv.getMin().getScore(); - ////int j = + ////int j = hsiv.fixIncr(0); ////cerr<<" new-pos="<<j<<"\n"; ////if(j!=0) for(int i=0;i<iNext;i++) cerr<<" "<<i<<": ln"<<hsiv.get(i).second.getRef().lineNum.toInt()<<" new-score="<<double(hsiv.get(i).getScore())<<"\n"; @@ -151,7 +151,7 @@ pair<typename V::ElementType,int> ArchetypeSet<V>::getDistanceOfNearest ( const hsiv.set(iNext).second = SafePtr<const NV> ( iUpper->second ); typename V::ElementType d = v.getMarginalDistance ( hsiv.get(iNext).first, hsiv.get(iNext).second.getRef() ); hsiv.set(iNext).setScore() = d; - ////int j = + ////int j = hsiv.fixDecr(iNext); ////cerr<<" adding ln"<<&hsiv.get(j).second.getRef()<<" marg-dist="<<d<<" new-score="<<double(hsiv.get(j).getScore())<<" new-pos="<<j<<"\n"; iNext++; @@ -164,7 +164,7 @@ pair<typename V::ElementType,int> ArchetypeSet<V>::getDistanceOfNearest ( const hsiv.set(iNext).second = SafePtr<const NV> ( iLower->second ); typename V::ElementType d = v.getMarginalDistance ( hsiv.get(iNext).first, hsiv.get(iNext).second.getRef() ); hsiv.set(iNext).setScore() = d; - ////int j = + ////int j = hsiv.fixDecr(iNext); ////cerr<<" adding ln"<<&hsiv.get(j).second.getRef()<<" marg-dist="<<d<<" new-score="<<double(hsiv.get(j).getScore())<<" new-pos="<<j<<"\n"; iNext++; diff --git a/contrib/synlm/hhmm/rvtl/include/nl-array.h b/contrib/synlm/hhmm/rvtl/include/nl-array.h index 0dfb74b44..6c6e1bb5f 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-array.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-array.h @@ -27,7 +27,7 @@ #include <cassert> #include <iostream> -using namespace std; +using namespace std; //////////////////////////////////////////////////////////////////////////////// diff --git a/contrib/synlm/hhmm/rvtl/include/nl-beam.h b/contrib/synlm/hhmm/rvtl/include/nl-beam.h index 398babe21..817e96206 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-beam.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-beam.h @@ -101,8 +101,8 @@ class Beam { void write(FILE *pf){ /* for (typename BeamMap::const_iterator i = mkid.begin(); i != mkid.end(); i++){ i->first.write(pf); - fprintf(pf, " %d ", i->second.first); -// i->second.second.write(pf); + fprintf(pf, " %d ", i->second.first); +// i->second.second.write(pf); fprintf(pf, "\n"); } */ diff --git a/contrib/synlm/hhmm/rvtl/include/nl-cpt.h b/contrib/synlm/hhmm/rvtl/include/nl-cpt.h index a7c1a916c..dbfb947e3 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-cpt.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-cpt.h @@ -394,7 +394,7 @@ class SimpleMap : public map<X,Y> { private: typedef map<X,Y> OrigMap; static const Y yDummy; - + public: // Constructor / destructor methods... SimpleMap ( ) : OrigMap() { } @@ -899,7 +899,7 @@ class GenericHidVarCPTModel : public SimpleHash<K,typename Y::template ArrayDist const typename Y::template ArrayDistrib<P>& getDistrib ( const K& k ) const { return HKYP::get(k); } - + P& setProb ( const Y& y, const K& k ) { pair<typename Y::BaseType,P>& yp = HKYP::set(k).add(); yp.first = y; diff --git a/contrib/synlm/hhmm/rvtl/include/nl-crf.h b/contrib/synlm/hhmm/rvtl/include/nl-crf.h index 44744ad03..a9b233b23 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-crf.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-crf.h @@ -36,7 +36,7 @@ // //////////////////////////////////////////////////////////////////////////////// -template <class Y,class X1,class X2> +template <class Y,class X1,class X2> class CRF3DModeledRV : public Y { private: @@ -90,7 +90,7 @@ template <class Y,class X1,class X2> SafeArray5D<Id<int>,int,int,int,int,float> //////////////////////////////////////////////////////////////////////////////// -template <class Y,class X1,class X2> +template <class Y,class X1,class X2> Prob CRF3DModeledRV<Y,X1,X2>::getProb( const X1& x1, const X2& x2 ) const { SafeArray2D<int,int,int> aaCnds ( cardOff, cardSh ) ; @@ -131,7 +131,7 @@ Prob CRF3DModeledRV<Y,X1,X2>::getProb( const X1& x1, const X2& x2 ) const { for ( int configRghtValSite=0; configRghtValSite<(1<<bitsValSite); configRghtValSite++ ) for ( int configValOverlap=0; configValOverlap<(1<<(bitsVal-bitsValSite)); configValOverlap++ ) { int configRghtVal = (configValOverlap<<bitsValSite)+configRghtValSite; - // For each possible preceding trellis node... + // For each possible preceding trellis node... for ( int configLeftValSite=0; configLeftValSite<(1<<bitsValSite); configLeftValSite++ ) { int configLeftVal = (configLeftValSite<<(bitsVal-bitsValSite))+configValOverlap; // Add product of result and previous trellis cell to current trellis cell... @@ -158,7 +158,7 @@ Prob CRF3DModeledRV<Y,X1,X2>::getProb( const X1& x1, const X2& x2 ) const { //////////////////////////////////////////////////////////////////////////////// -template <class Y,class X1,class X2> +template <class Y,class X1,class X2> bool CRF3DModeledRV<Y,X1,X2>::readModelFields ( char* aps[], int numFields ) { if ( 7==numFields ) setPotential ( X1(string(aps[1])), // globals @@ -172,7 +172,7 @@ bool CRF3DModeledRV<Y,X1,X2>::readModelFields ( char* aps[], int numFields ) { //////////////////////////////////////////////////////////////////////////////// -template <class Y,class X1,class X2> +template <class Y,class X1,class X2> void CRF3DModeledRV<Y,X1,X2>::writeObservCliqueConfigs ( FILE* pf, int frame, const char* psMdl, const X1& x1, const X2& x2, bool bObsVal ) const { fprintf ( pf, "%04d> %s ", frame, psMdl ); @@ -199,7 +199,7 @@ void CRF3DModeledRV<Y,X1,X2>::writeObservCliqueConfigs ( FILE* pf, int frame, co // //////////////////////////////////////////////////////////////////////////////// -template <class Y,class X1,class X2,class X3> +template <class Y,class X1,class X2,class X3> class CRF4DModeledRV : public Y { private: @@ -247,13 +247,13 @@ template <class Y,class X1,class X2,class X3> int CRF4DModeledRV<Y,X1,X2,X3>::c template <class Y,class X1,class X2,class X3> int CRF4DModeledRV<Y,X1,X2,X3>::cardCnd = 0; template <class Y,class X1,class X2,class X3> int CRF4DModeledRV<Y,X1,X2,X3>::bitsVal = 0; template <class Y,class X1,class X2,class X3> int CRF4DModeledRV<Y,X1,X2,X3>::bitsValSite = 0; -template <class Y,class X1,class X2,class X3> SafeArray5D<Id<int>,int,int,int,int,float> +template <class Y,class X1,class X2,class X3> SafeArray5D<Id<int>,int,int,int,int,float> CRF4DModeledRV<Y,X1,X2,X3>::aaaaaPotentials; /* template <class Y,class X1,class X2> SafeArray3D<int> CRF4DModeledRV<Y,X1,X2>::aaaCnds; */ //////////////////////////////////////////////////////////////////////////////// -template <class Y,class X1,class X2,class X3> +template <class Y,class X1,class X2,class X3> Prob CRF4DModeledRV<Y,X1,X2,X3>::getProb( const X1& x1, const X2& x2, const X3& x3 ) const { SafeArray2D<int,int,int> aaCnds ( cardOff, cardSh ) ; @@ -294,7 +294,7 @@ Prob CRF4DModeledRV<Y,X1,X2,X3>::getProb( const X1& x1, const X2& x2, const X3& for ( int configRghtValSite=0; configRghtValSite<(1<<bitsValSite); configRghtValSite++ ) for ( int configValOverlap=0; configValOverlap<(1<<(bitsVal-bitsValSite)); configValOverlap++ ) { int configRghtVal = (configValOverlap<<bitsValSite)+configRghtValSite; - // For each possible preceding trellis node... + // For each possible preceding trellis node... for ( int configLeftValSite=0; configLeftValSite<(1<<bitsValSite); configLeftValSite++ ) { int configLeftVal = (configLeftValSite<<(bitsVal-bitsValSite))+configValOverlap; // Add product of result and previous trellis cell to current trellis cell... @@ -321,7 +321,7 @@ Prob CRF4DModeledRV<Y,X1,X2,X3>::getProb( const X1& x1, const X2& x2, const X3& //////////////////////////////////////////////////////////////////////////////// -template <class Y,class X1,class X2,class X3> +template <class Y,class X1,class X2,class X3> bool CRF4DModeledRV<Y,X1,X2,X3>::readModelFields ( char* aps[], int numFields ) { if ( 7==numFields ) setPotential ( X1(string(aps[1])), // globals @@ -335,9 +335,9 @@ bool CRF4DModeledRV<Y,X1,X2,X3>::readModelFields ( char* aps[], int numFields ) //////////////////////////////////////////////////////////////////////////////// -template <class Y,class X1,class X2, class X3> +template <class Y,class X1,class X2, class X3> void CRF4DModeledRV<Y,X1,X2,X3>::writeObservCliqueConfigs ( FILE* pf, int frame, const char* psMdl, - const X1& x1, const X2& x2, + const X1& x1, const X2& x2, const X3& x3, bool bObsVal ) const { fprintf ( pf, "%04d> %s ", frame, psMdl ); // For each shape (feature slope)... diff --git a/contrib/synlm/hhmm/rvtl/include/nl-denot.h b/contrib/synlm/hhmm/rvtl/include/nl-denot.h index 0b50663a1..be92168b8 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-denot.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-denot.h @@ -80,7 +80,7 @@ void VecE<N,I,RC>::read ( char* ps, const ReaderContext& rc ) { */ char* psT; int i=0; for ( char* psU=strtok_r(ps,",",&psT); - psU && i<NUM_ENTS; + psU && i<NUM_ENTS; psU=strtok_r(NULL,",",&psT),i++ ) StaticSafeArray<N,I>::set(i) = psU; } @@ -166,7 +166,7 @@ void VecV<N,I,RC,ND1,ND2>::read ( char* ps, VecVReaderContext& rc ) { // Chop into individual coinds strings... char* psT; int i=0; for ( char* psU=strtok_r(ps,",",&psT); - psU && i<NUM_ENTS; + psU && i<NUM_ENTS; psU=strtok_r(NULL,",",&psT), i++ ) asV.set(i) = psU; @@ -230,7 +230,7 @@ class JointVecV { //// : public StaticSafeArray<V1::NUM_ENTS+V2::NUM_ENTS,I> { static const int NUM_ENTS; // Constructor / destructor methods... JointVecV ( ) { } - JointVecV ( const V1& a1, const V2& a2 ) { + JointVecV ( const V1& a1, const V2& a2 ) { ////fprintf(stderr,"iJoin "); a1.V1::write(stderr); fprintf(stderr," "); a2.V2::write(stderr); fprintf(stderr,"\n"); for (int i=0; i<NUM_ENTS; i++) { if ( i<V1::NUM_ENTS ) set(i) = (a1.get(i)==-1) ? IntType(-1) : (a1.get(i)<V1::NUM_ENTS) ? IntType(a1.get(i)) : a1.get(i)+V2::NUM_ENTS; diff --git a/contrib/synlm/hhmm/rvtl/include/nl-dtree-cont.h b/contrib/synlm/hhmm/rvtl/include/nl-dtree-cont.h index cf6b00d28..1deb757a5 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-dtree-cont.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-dtree-cont.h @@ -75,7 +75,7 @@ class ContDTree2DModel : public Generic2DModel<Y,X,P>, public Tree<ContDecisNode // Extraction methods... const P getProb ( const Y y, const X& x ) const { const Tree<ContDecisNode<Y,P> >* ptr = this; - while ( !ptr->isTerm() ) { + while ( !ptr->isTerm() ) { double sumsqr=0.0; for(A a;a<X::getSize();a.setNext()) sumsqr += pow(x.get(a.toInt()),2.0) / X::getSize(); Wt wtdavg = -Tree<ContDecisNode<Y,P> >::getWt(); @@ -112,7 +112,7 @@ class ContDTree2DModel : public Generic2DModel<Y,X,P>, public Tree<ContDecisNode }; //////////////////// -template <class Y,class X, class P> +template <class Y,class X, class P> bool ContDTree2DModel<Y,X,P>::readFields ( char* aps[], int numFields ) { if ( /*aps[0]==sId &&*/ (3==numFields || 4==numFields) ) { //fprintf(stderr,"%s,%d\n",aps[3],numFields); @@ -171,7 +171,7 @@ class ContDTree3DModel : public Generic3DModel<Y,X1,X2,P> { }; //////////////////// -template <class Y,class X1,class X2, class P> +template <class Y,class X1,class X2, class P> bool ContDTree3DModel<Y,X1,X2,P>::readFields ( char* aps[], int numFields ) { if ( /*aps[0]==sId &&*/ (4==numFields || 5==numFields) ) { //fprintf(stderr,"%s,%d\n",aps[3],numFields); @@ -212,7 +212,7 @@ bool ContDTree3DModel<Y,X1,X2,P>::readFields ( char* aps[], int numFields ) { //////////////////////////////////////////////////////////////////////////////// template<class Y, class X, class P> -class TrainableContDTree2DModel : public ContDTree2DModel<Y,X,P> { +class TrainableContDTree2DModel : public ContDTree2DModel<Y,X,P> { private: List<Joint2DRV<X,Y> > lxy; public: @@ -225,7 +225,7 @@ class TrainableContDTree2DModel : public ContDTree2DModel<Y,X,P> { void train ( List<Joint2DRV<X,Y> >&, const double ) ; void train ( const double d ) { train(lxy,d); } ////// Input / output methods... - bool readData ( char* vs[], int numFields ) { + bool readData ( char* vs[], int numFields ) { if ( 3==numFields ) lxy.add() = Joint2DRV<X,Y> ( X(vs[1]), Y(vs[2]) ); else return false; return true; @@ -312,7 +312,7 @@ void TrainableContDTree2DModel<Y,X,P>::train ( List<Joint2DRV<X,Y> >& lxy, cons // if ( double(rand())/double(RAND_MAX) < prRarest/modelY.getProb(pxy->getSub2()) ) { dCtr++; - double gamma = dTot/(dTot+dCtr); // 1.0/(double(epoch)+dCtr/dTot); // 1.0/double(epoch); // 1.0/(double(epoch)+dCtr/(dTot*prRarest*2.0)); // + double gamma = dTot/(dTot+dCtr); // 1.0/(double(epoch)+dCtr/dTot); // 1.0/double(epoch); // 1.0/(double(epoch)+dCtr/(dTot*prRarest*2.0)); // // Weight deltas for next epoch... Wt wDelta = 0.0; @@ -333,7 +333,7 @@ void TrainableContDTree2DModel<Y,X,P>::train ( List<Joint2DRV<X,Y> >& lxy, cons P prY = 1.0 / ( 1.0 + exp(-wtdavg) ); // Calc deltas for each feature/attribute/dimension... - double dEachWt = 1.0/dTot; // 1.0/dTot * modelY.getProb ( Y(1-pxy->getSub2().toInt()) ); // 1.0/(dTot*prRarest*2.0); // + double dEachWt = 1.0/dTot; // 1.0/dTot * modelY.getProb ( Y(1-pxy->getSub2().toInt()) ); // 1.0/(dTot*prRarest*2.0); // wDelta += dEachWt * -1 * ( prY - P(double(pxy->getSub2().toInt())) ); for ( A a; a<X::getSize(); a.setNext() ) awDeltas.set(a) += dEachWt * pxy->getSub1().get(a.toInt()) * ( prY - P(double(pxy->getSub2().toInt())) ); @@ -439,7 +439,7 @@ void TrainableContDTree2DModel<Y,X,P>::train ( List<Joint2DRV<X,Y> >& lxy, cons //////////////////////////////////////////////////////////////////////////////// template<class Y, class X1, class X2, class P> -class TrainableContDTree3DModel : public ContDTree3DModel<Y,X1,X2,P> { +class TrainableContDTree3DModel : public ContDTree3DModel<Y,X1,X2,P> { private: @@ -455,7 +455,7 @@ class TrainableContDTree3DModel : public ContDTree3DModel<Y,X1,X2,P> { TrainableContDTree2DModel<Y,X2,P>& setTree(const X1& x1) { return static_cast<TrainableContDTree2DModel<Y,X2,P>&>(ContDTree3DModel<Y,X1,X2,P>::setTree(x1)); } ////// Add training data to per-subphone lists... - bool readData ( char* vs[], int numFields ) { + bool readData ( char* vs[], int numFields ) { if ( 4==numFields ) { mqlxy[X1(vs[1])].add() = Joint2DRV<X2,Y> ( X2(vs[2]), Y(vs[3]) ); ////mqlxy[X1(vs[1])].getLast()->write(stderr); fprintf(stderr,"\n"); diff --git a/contrib/synlm/hhmm/rvtl/include/nl-dtree.h b/contrib/synlm/hhmm/rvtl/include/nl-dtree.h index 2396f395c..93a0e4d42 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-dtree.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-dtree.h @@ -129,8 +129,8 @@ class DTree2DModel : public Tree < typename X::ElementType, DecisNode<X,Y,P> > { friend StringInput operator>> ( pair<StringInput,DTree2DModel<Y,X,P>*> si_m, const char* psD ) { if (StringInput(NULL)==si_m.first) return si_m.first; Y y; String xs; StringInput si,si2; si=si_m.first; DTree2DModel<Y,X,P>* pm=si_m.second; - while((si2=si>>" ")!=NULL)si=si2; - si=si>>xs>>" "; + while((si2=si>>" ")!=NULL)si=si2; + si=si>>xs>>" "; while((si2=si>>" ")!=NULL)si=si2; // Find appropriate node, creating nodes as necessary... for(int i=1; i<int(strlen(xs.c_array()))-1; i++) { @@ -140,22 +140,22 @@ class DTree2DModel : public Tree < typename X::ElementType, DecisNode<X,Y,P> > { if ( si!=NULL && si[0]==':' ) { si=si>>": "; - while((si2=si>>" ")!=NULL)si=si2; + while((si2=si>>" ")!=NULL)si=si2; si=si>>y>>" "; - while((si2=si>>" ")!=NULL)si=si2; + while((si2=si>>" ")!=NULL)si=si2; si=si>>"= "; - while((si2=si>>" ")!=NULL)si=si2; + while((si2=si>>" ")!=NULL)si=si2; // Specify attribute number (at nonterminal) or probability in distribution (at terminal)... return (si!=NULL) ? si>>pm->setProb(y)>>psD : si; } else if ( si!=NULL && si[0]=='=' ) { si=si>>"= "; //cerr<<" in after equals "<<((si==NULL) ? "yes" : "no") << endl; - while((si2=si>>" ")!=NULL)si=si2; + while((si2=si>>" ")!=NULL)si=si2; //m.setA() = atoi(si.c_str()); int aVar = 0; - si=si>>aVar>>psD; - pm->setA()=aVar; + si=si>>aVar>>psD; + pm->setA()=aVar; ////cerr<<" at end "<<((si==NULL) ? "yes" : "no") << endl; ////cerr<<" m.getA() is "<< m.getA().toInt() << endl; return si; @@ -169,15 +169,15 @@ class DTree2DModel : public Tree < typename X::ElementType, DecisNode<X,Y,P> > { si=si_m.first; sRt = si.c_str(); if (sRt.find(':')!=string::npos) { - while((si2=si>>" [")!=NULL)si=si2; - si=si>>xs>>"] "; - while((si2=si>>" ")!=NULL)si=si2; + while((si2=si>>" [")!=NULL)si=si2; + si=si>>xs>>"] "; + while((si2=si>>" ")!=NULL)si=si2; si=si>>": "; - while((si2=si>>" ")!=NULL)si=si2; + while((si2=si>>" ")!=NULL)si=si2; si=si>>y>>" "; - while((si2=si>>" ")!=NULL)si=si2; + while((si2=si>>" ")!=NULL)si=si2; si=si>>"= "; - + // For DTree, must find the node labeled by X //Tree<B,DecisNode<X,Y,P> >* ptr = m; //assert(ptr); @@ -189,15 +189,15 @@ class DTree2DModel : public Tree < typename X::ElementType, DecisNode<X,Y,P> > { // Specify attribute number (at nonterminal) or probability in distribution (at terminal)... return (si!=NULL) ? si>>m.setProb(y)>>psD : si; } else { - while((si2=si>>" [")!=NULL)si=si2; + while((si2=si>>" [")!=NULL)si=si2; si=si>>xs>>"] "; //cerr<<" in bracket "<<((si==NULL) ? "yes" : "no") << endl; - while((si2=si>>" ")!=NULL)si=si2; + while((si2=si>>" ")!=NULL)si=si2; si=si>>"= "; //cerr<<" in after equals "<<((si==NULL) ? "yes" : "no") << endl; //m.setA() = atoi(si.c_str()); int aVar = 0; - si=si>>aVar>>psD; - m.setA()=aVar; + si=si>>aVar>>psD; + m.setA()=aVar; //cerr<<" at end "<<((si==NULL) ? "yes" : "no") << endl; //cerr<<" m.getA() is "<< m.getA().toInt() << endl; return si; @@ -209,7 +209,7 @@ class DTree2DModel : public Tree < typename X::ElementType, DecisNode<X,Y,P> > { }; //////////////////// -template <class Y,class X, class P> +template <class Y,class X, class P> bool DTree2DModel<Y,X,P>::readFields ( Array<char*>& aps ) { if ( /*aps[0]==sId &&*/ (3==aps.size() || 4==aps.size()) ) { //fprintf(stderr,"%s,%d\n",aps[3],numFields); @@ -269,7 +269,7 @@ class DTree3DModel { }; //////////////////// -template <class Y,class X1,class X2, class P> +template <class Y,class X1,class X2, class P> bool DTree3DModel<Y,X1,X2,P>::readFields ( char* aps[], int numFields ) { if ( /*aps[0]==sId &&*/ (4==numFields || 5==numFields) ) { //fprintf(stderr,"%s,%d\n",aps[3],numFields); @@ -307,7 +307,7 @@ bool DTree3DModel<Y,X1,X2,P>::readFields ( char* aps[], int numFields ) { //////////////////////////////////////////////////////////////////////////////// template<class Y, class X, class P> -class TrainableDTree2DModel : public DTree2DModel<Y,X,P> { +class TrainableDTree2DModel : public DTree2DModel<Y,X,P> { private: // Type members... typedef typename X::ElementType B; @@ -485,7 +485,7 @@ void TrainableDTree2DModel<Y,X,P>::train ( List<Joint2DRV<X,Y> >& lxy, const De //////////////////////////////////////////////////////////////////////////////// template<class Y, class X1, class X2, class P> -class TrainableDTree3DModel : public DTree3DModel<Y,X1,X2,P> { +class TrainableDTree3DModel : public DTree3DModel<Y,X1,X2,P> { private: diff --git a/contrib/synlm/hhmm/rvtl/include/nl-fixedmatrix.h b/contrib/synlm/hhmm/rvtl/include/nl-fixedmatrix.h index dbb9d9d9d..5e8b4d6d0 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-fixedmatrix.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-fixedmatrix.h @@ -34,7 +34,7 @@ class Matrix : public SafeArray2D<Id<int>,Id<int>,T> { Matrix ( ) : SafeArray2D<Id<int>,Id<int>,T>( ) { }//{ xSize=0; ySize=0; } Matrix (int x, int y) : SafeArray2D<Id<int>,Id<int>,T>(x,y) { }//{ xSize=x; ySize=y; } Matrix (int x, int y, const T& t) : SafeArray2D<Id<int>,Id<int>,T>(x,y,t) { }//{ xSize=x; ySize=y; } - Matrix (const Matrix& a) : SafeArray2D<Id<int>,Id<int>,T>(a.xSize(),a.ySize()) { //xSize=a.xSize; ySize=a.ySize; + Matrix (const Matrix& a) : SafeArray2D<Id<int>,Id<int>,T>(a.xSize(),a.ySize()) { //xSize=a.xSize; ySize=a.ySize; for(int i=0;i<xSize();i++) for(int j=0;j<ySize();j++) this->set(i,j)=a.get(i,j); } // Specification methods... //Matrix& operator= ( const Matrix<T>& sat ) @@ -195,34 +195,34 @@ class Matrix : public SafeArray2D<Id<int>,Id<int>,T> { } return false; } - bool operator== ( const Matrix<T>& a ) const { + bool operator== ( const Matrix<T>& a ) const { if (xSize()!=a.xSize() || ySize()!=a.ySize()) return false; - for (int i=0;i<a.xSize();i++) + for (int i=0;i<a.xSize();i++) for (int j=0;j<a.ySize();j++) if (this->get(Id<int>(i),Id<int>(j))!=a.get(Id<int>(i),Id<int>(j))) return false; return true; } // Input/output methods... - friend ostream& operator<< ( ostream& os, const Matrix<T>& a ) { + friend ostream& operator<< ( ostream& os, const Matrix<T>& a ) { os<<"\n "; for (int i=0;i<a.xSize();i++) { for (int j=0;j<a.ySize();j++) { os<<((j==0)?"":",")<<a.get(Id<int>(i),Id<int>(j)); - } + } os<<(i==a.xSize()-1?"\n":"\n "); } - return os; + return os; } - friend String& operator<< ( String& str, const Matrix<T>& a ) { + friend String& operator<< ( String& str, const Matrix<T>& a ) { str<<"\n "; for (int i=0;i<a.xSize();i++) { for (int j=0;j<a.ySize();j++) { str<<((j==0)?"":",")<<a.get(Id<int>(i),Id<int>(j)); - } + } str<<";"; } - return str; + return str; } string getString( ) const; @@ -234,7 +234,7 @@ string Matrix<T>::getString() const { for (int j=0;j<ySize();j++) { str += ((j==0)?"":","); str += this->get(Id<int>(i),Id<int>(j)); - } + } str += ";"; } return str; diff --git a/contrib/synlm/hhmm/rvtl/include/nl-gauss.h b/contrib/synlm/hhmm/rvtl/include/nl-gauss.h index a2213086f..f5cc45159 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-gauss.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-gauss.h @@ -43,7 +43,7 @@ static const PDFVal VARIANCE_THRESHOLD = 0.01; //0.0001; //0 // //////////////////////////////////////////////////////////////////////////////// -template <class Y> +template <class Y> class DiagGauss1DModel : public Generic1DModel<Y,PDFVal> { private: // Member variables... @@ -53,7 +53,7 @@ class DiagGauss1DModel : public Generic1DModel<Y,PDFVal> { SimpleHash<Id<int>,PDFVal> aMeans; SimpleHash<Id<int>,PDFVal> aVariances; PDFVal prInvRootNormVariances; - PDFVal prProduct; + PDFVal prProduct; SimpleHash<Id<int>,PDFVal> algprNegHalfInvVariances; public: // Constructor / destructor methods... @@ -78,7 +78,7 @@ class DiagGauss1DModel : public Generic1DModel<Y,PDFVal> { }; //////////////////////////////////////// -template <class Y> +template <class Y> inline void DiagGauss1DModel<Y>::precomputeVarianceTerms ( ) { // Inverse square root of norm of variances... setInvRootNormVar() = 1.0; @@ -92,7 +92,7 @@ inline void DiagGauss1DModel<Y>::precomputeVarianceTerms ( ) { } //////////////////////////////////////// -template <class Y> +template <class Y> inline PDFVal DiagGauss1DModel<Y>::getProb ( const Y& y ) const { // fprintf(stderr,"--------------------\n"); // y.write(stderr); @@ -109,7 +109,7 @@ inline PDFVal DiagGauss1DModel<Y>::getProb ( const Y& y ) const { } //////////////////////////////////////// -template <class Y> +template <class Y> bool DiagGauss1DModel<Y>::readFields ( char* as[], int numFields ) { if ( 0==strcmp(as[1],"m") && numFields>2 ) { char* psT; @@ -126,12 +126,12 @@ bool DiagGauss1DModel<Y>::readFields ( char* as[], int numFields ) { } //////////////////////////////////////// -template <class Y> +template <class Y> void DiagGauss1DModel<Y>::writeFields ( FILE* pf, const string& sPref ) const { fprintf(pf,"%s m = ",sPref.c_str()); for(int i=0; i<getNumFeats(); i++) fprintf(pf,"%s%f",(0==i)?"":"_",getMean(i)); fprintf ( pf, "\n" ) ; - + fprintf(pf,"%s v = ",sPref.c_str()); for(int i=0; i<getNumFeats(); i++) fprintf(pf,"%s%f",(0==i)?"":"_",getVariance(i)); fprintf ( pf, "\n" ) ; @@ -141,7 +141,7 @@ void DiagGauss1DModel<Y>::writeFields ( FILE* pf, const string& sPref ) const { //////////////////////////////////////////////////////////////////////////////// /* -template <class Y,class X> +template <class Y,class X> class DiagGauss2DModel : public Generic2DModel<Y,X,PDFVal> { private: // Member variables... @@ -177,7 +177,7 @@ class DiagGauss2DModel : public Generic2DModel<Y,X,PDFVal> { //////////////////////////////////////////////////////////////////////////////// -template <class Y,class X1,class X2> +template <class Y,class X1,class X2> class DiagGauss3DModel : public Generic3DModel<Y,X1,X2,PDFVal> { private: // Member variables... @@ -220,7 +220,7 @@ class DiagGauss3DModel : public Generic3DModel<Y,X1,X2,PDFVal> { // //////////////////////////////////////////////////////////////////////////////// -template <class Y> +template <class Y> class TrainableDiagGauss1DModel : public DiagGauss1DModel<Y> { public: TrainableDiagGauss1DModel ( ) : DiagGauss1DModel<Y>() { } diff --git a/contrib/synlm/hhmm/rvtl/include/nl-hash.h b/contrib/synlm/hhmm/rvtl/include/nl-hash.h index 809284db9..b4d228b9c 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-hash.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-hash.h @@ -54,7 +54,7 @@ class SimpleHash : public hash_map<X,Y,SimpleHashFn<X>,SimpleHashEqual<X> > /*pu // tr1::unordered_map<X,Y,SimpleHashFn<X>,SimpleHashEqual<X> > mxy; static const Y yDummy; //static Y yNonconstDummy; - + public: // typedef typename OrigHash::const_iterator const_iterator; // typedef typename OrigHash::iterator iterator; diff --git a/contrib/synlm/hhmm/rvtl/include/nl-hmm.h b/contrib/synlm/hhmm/rvtl/include/nl-hmm.h index 2f6cd0104..c4414c4b7 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-hmm.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-hmm.h @@ -209,7 +209,7 @@ template <class MY, class MX, class S, class B> void HMM<MY,MX,S,B>::debugPrint() const{ for (int frame=0, numFrames=aatnTrellis.getxSize(); frame<numFrames; frame++) { - + for (int beamIndex=0, beamSize=aatnTrellis.getySize(); beamIndex<beamSize; beamIndex++) { if (aatnTrellis.get(frame,beamIndex).getLogProb().toDouble() > 0) { @@ -306,7 +306,7 @@ void HMM<MY,MX,S,B>::updateRanked ( const typename MX::RandVarType& x, bool b1 ) // Add best transition (top of queue)... //mx.getProb(o,my.setTrellDat(ashpiQueue.getTop().first,ashpiQueue.getTop().second)); if ( ashpiQueue.getSize() > 0 ) { - S s; my.setTrellDat(s,ashpiQueue.getTop().second); + S s; my.setTrellDat(s,ashpiQueue.getTop().second); bFull |= btn.tryAdd ( s, IB(ashpiQueue.getTop().first,my.setBackDat(ashpiQueue.getTop().second)), ashpiQueue.getTop().third ); ////cerr<<ashpiQueue.getSize()<<" queue elems A "<<ashpiQueue.getTop()<<"\n"; ////cerr<<"/-----A-----\\\n"<<ashpiQueue<<"\\-----A-----/\n"; @@ -379,7 +379,7 @@ void HMM<MY,MX,S,B>::updateSerial ( const typename MX::RandVarType& x ) { // Incorporate into trellis... btn.tryAdd ( s, IB(i,my.setBackDat(y)), lgprFull ); //if(OUTPUT_VERYNOISY) - // fprintf ( stderr," (S_t-1:[e^%0.6f] * Y:e^%0.6f * X:e^%0.6f = S_t:[e^%0.6f])\n", + // fprintf ( stderr," (S_t-1:[e^%0.6f] * Y:e^%0.6f * X:e^%0.6f = S_t:[e^%0.6f])\n", // float(aatnTrellis.get(frameLast-1,i).getLogProb().toInt())/100.0, // float(lgprY.toInt())/100.0, // float(lgprX.toInt())/100.0, @@ -389,7 +389,7 @@ void HMM<MY,MX,S,B>::updateSerial ( const typename MX::RandVarType& x ) { } // for(int i=0;i<BEAM_WIDTH;i++) { -// fprintf(stderr,"> "); btn.get(i)->first.write(stderr); fprintf(stderr,"\n"); +// fprintf(stderr,"> "); btn.get(i)->first.write(stderr); fprintf(stderr,"\n"); // } btn.sort(atnSorted); @@ -429,8 +429,8 @@ void HMM<MY,MX,S,B>::each ( const typename MX::RandVarType& x, Beam<LogProb,S,IB const TrellNode<S,B>& tnsbPrev = aatnTrellis.get(frameLast-1,i); // If prob still not below beam minimum... if ( tnsbPrev.getLogProb() > btn.getMin().getScore() ) { - //if (OUTPUT_VERYNOISY) { fprintf(stderr,"FROM: "); tnsbPrev.getId().write(stderr); fprintf(stderr,"\n"); } - + //if (OUTPUT_VERYNOISY) { fprintf(stderr,"FROM: "); tnsbPrev.getId().write(stderr); fprintf(stderr,"\n"); } + // For each possible transition... const S& sPrev = tnsbPrev.getId(); typename MY::IterVal y; @@ -447,7 +447,7 @@ void HMM<MY,MX,S,B>::each ( const typename MX::RandVarType& x, Beam<LogProb,S,IB lgprX = mx.getProb(x,my.setTrellDat(s,y)); if ( !OUTPUT_VERYNOISY && LogProb()==lgprX ) continue; #endif ///////////////////////////////////////////////////////////////// lgprFull = tnsbPrev.getLogProb() * lgprY * lgprX; - if (OUTPUT_VERYNOISY) { + if (OUTPUT_VERYNOISY) { boost::mutex::scoped_lock lock1(mutexHmmParanoiaLock); //fprintf(stderr," TO: "); y.write(stderr); fprintf(stderr,"\n"); cout<<" "<<tnsbPrev.getId()<<" ==("<<tnsbPrev.getLogProb().toInt()<<"*"<<lgprY.toInt()<<"*"<<lgprX.toInt()<<"="<<lgprFull.toInt()<<")==> "<<y<<"\n"; @@ -459,7 +459,7 @@ void HMM<MY,MX,S,B>::each ( const typename MX::RandVarType& x, Beam<LogProb,S,IB // Incorporate into trellis... btn.tryAdd ( s, IB(i,my.setBackDat(y)), lgprFull ); // if(OUTPUT_VERYNOISY) -// fprintf ( stderr," (S_t-1:[e^%0.6f] * Y:e^%0.6f * X:e^%0.6f = S_t:[e^%0.6f])\n", +// fprintf ( stderr," (S_t-1:[e^%0.6f] * Y:e^%0.6f * X:e^%0.6f = S_t:[e^%0.6f])\n", // float(aatnTrellis.get(frameLast-1,i).getLogProb().toInt())/100.0, // float(lgprY.toInt())/100.0, // float(lgprO.toInt())/100.0, @@ -695,7 +695,7 @@ std::list<string> HMM<MY,MX,S,B>::getMLS(const S& sLast) const { //// sprintf(tmp,"HYPOTH %04d> ", fr-1); //// string tString(tmp); //// tString += - string tString = + string tString = //// aatnTrellis.get(fr,iBest).getId().getString() + " " + aatnTrellis.get(fr,iBest).getBackData().getString() //// + "\n" @@ -737,7 +737,7 @@ template <class MY, class MX, class S, class B> void HMM<MY,MX,S,B>::writeCurr ( ostream& os, int f=-1 ) const { if ( -1==f ) f=frameLast; if ( 0<=f && f<=frameLast ) - for ( int i=0; i<BEAM_WIDTH; i++ ) + for ( int i=0; i<BEAM_WIDTH; i++ ) if(!(aatnTrellis.get(f,i).getLogProb() == LogProb())){ //fprintf(pf,"at f=%04d b=%04d: ",f,i); os<<"at "<<std::setfill('0')<<std::setw(4)<<f<<" "<<std::setw(4)<<i<<": "; @@ -765,7 +765,7 @@ void HMM<MY,MX,S,B>::writeCurrSum ( FILE* pf, int f=-1 ) const { if ( 0<=f && f<=frameLast ) { LogProb sum = 0.0; LogProb logtop = 0.0; - for ( int i=0; i<BEAM_WIDTH; i++ ) + for ( int i=0; i<BEAM_WIDTH; i++ ) if(!(aatnTrellis.get(f,i).getLogProb() == LogProb())){ if(i==0) { logtop=aatnTrellis.get(f,i).getLogProb(); } LogProb big1 = sum - logtop; @@ -818,7 +818,7 @@ void HMM<MY,MX,S,B>::gatherElementsInBeam( SafeArray1D<Id<int>,pair<S,LogProb> > result->init(BEAM_WIDTH); if ( -1==f ) f=frameLast; if ( 0<=f && f<=frameLast ) { - for ( int i=0; i<BEAM_WIDTH && &(aatnTrellis.get(f,i))!=NULL; i++ ) { + for ( int i=0; i<BEAM_WIDTH && &(aatnTrellis.get(f,i))!=NULL; i++ ) { result->set(i).first = aatnTrellis.get(f,i).getId(); result->set(i).second = aatnTrellis.get(f,i).getLogProb(); } @@ -836,7 +836,7 @@ void HMM<MY,MX,S,B>::writeCurrEntropy ( FILE* pf, int f=-1 ) const { if ( 0<=f && f<=frameLast ) { LogProb logh = 0.0; LogProb logtop = 0.0; - for ( int i=0; i<BEAM_WIDTH; i++ ) + for ( int i=0; i<BEAM_WIDTH; i++ ) if(!(aatnTrellis.get(f,i).getLogProb() == LogProb())){ if(i==0) { logtop=aatnTrellis.get(f,i).getLogProb(); } LogProb big1 = logh - logtop; @@ -862,12 +862,12 @@ void HMM<MY,MX,S,B>::writeCurrDepths ( FILE* pf, int f=-1 ) const { Array<int> depths = Array<int>(); Array<LogProb> logprobs = Array<LogProb>(); double avgdepth = 0.0; - for ( int i=0; i<BEAM_WIDTH; i++ ) + for ( int i=0; i<BEAM_WIDTH; i++ ) if(!(aatnTrellis.get(f,i).getLogProb() == LogProb())){ if(i==0) { logtop=aatnTrellis.get(f,i).getLogProb(); } logprobs.set(i) = aatnTrellis.get(f,i).getLogProb(); - + // loop over values in S node to find lowest meaningful depth for ( int j=0; j<aatnTrellis.get(f,i).getId().first.getSize(); j++) { // store the depth, if it's equal to G_BOT/G_BOT @@ -996,7 +996,7 @@ int HMM<MY,MX,S,B>::getBeamUsed ( int f=-1 ) const { if ( -1==f ) f=frameLast; int ctr=0; if ( 0<=f && f<=frameLast ) - for ( int i=0; i<BEAM_WIDTH; i++ ) + for ( int i=0; i<BEAM_WIDTH; i++ ) if(!(aatnTrellis.get(f,i).getLogProb() == LogProb())){ ctr++; } diff --git a/contrib/synlm/hhmm/rvtl/include/nl-hmm2.h b/contrib/synlm/hhmm/rvtl/include/nl-hmm2.h index 711d589be..04941088d 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-hmm2.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-hmm2.h @@ -269,7 +269,7 @@ void HMM<MH,MO,X,B>::updateRanked ( const typename MO::RandVarType& o ) { // Add best transition (top of queue)... //mo.getProb(o,mh.setTrellDat(axhpiQueue.getTop().first,axhpiQueue.getTop().second)); if ( axhpiQueue.getSize() > 0 ) { - X x; mh.setTrellDat(x,axhpiQueue.getTop().second); + X x; mh.setTrellDat(x,axhpiQueue.getTop().second); bFull |= btn.tryAdd ( x, IB(axhpiQueue.getTop().first,mh.setBackDat(axhpiQueue.getTop().second)), axhpiQueue.getTop().third ); //cerr<<axhpiQueue.getSize()<<" queue elems A "<<axhpiQueue.getTop()<<"\n"; //cerr<<"/-----A-----\\\n + bFull: "<<bFull<<"\naxhpiQueue: \n"<<axhpiQueue<<"\\-----A-----/\n"; @@ -341,7 +341,7 @@ void HMM<MH,MO,X,B>::updateSerial ( const typename MO::RandVarType& o ) { // Incorporate into trellis... btn.tryAdd ( x, IB(i,mh.setBackDat(h)), lgprFull ); //if(OUTPUT_VERYNOISY) - // fprintf ( stderr," (X_t-1:[e^%0.6f] * H:e^%0.6f * O:e^%0.6f = X_t:[e^%0.6f])\n", + // fprintf ( stderr," (X_t-1:[e^%0.6f] * H:e^%0.6f * O:e^%0.6f = X_t:[e^%0.6f])\n", // float(aatnTrellis.get(frameLast-1,i).getLogProb().toInt())/100.0, // float(lgprH.toInt())/100.0, // float(lgprO.toInt())/100.0, @@ -351,7 +351,7 @@ void HMM<MH,MO,X,B>::updateSerial ( const typename MO::RandVarType& o ) { } // for(int i=0;i<BEAM_WIDTH;i++) { -// fprintf(stderr,"> "); btn.get(i)->first.write(stderr); fprintf(stderr,"\n"); +// fprintf(stderr,"> "); btn.get(i)->first.write(stderr); fprintf(stderr,"\n"); // } btn.sort(atnSorted); @@ -390,8 +390,8 @@ void HMM<MH,MO,X,B>::each ( const typename MO::RandVarType& o, Beam<LogProb,X,IB const TrellNode<X,B>& tnxbPrev = aatnTrellis.get(frameLast-1,i); // If prob still not below beam minimum... if ( tnxbPrev.getLogProb() > btn.getMin().getScore() ) { - //if (OUTPUT_VERYNOISY) { fprintf(stderr,"FROM: "); tnxbPrev.getId().write(stderr); fprintf(stderr,"\n"); } - + //if (OUTPUT_VERYNOISY) { fprintf(stderr,"FROM: "); tnxbPrev.getId().write(stderr); fprintf(stderr,"\n"); } + // For each possible transition... const X& xPrev = tnxbPrev.getId(); typename MH::IterVal h; @@ -408,7 +408,7 @@ void HMM<MH,MO,X,B>::each ( const typename MO::RandVarType& o, Beam<LogProb,X,IB lgprO = mo.getProb(o,mh.setTrellDat(x,h)); if ( !OUTPUT_VERYNOISY && LogProb()==lgprO ) continue; #endif ///////////////////////////////////////////////////////////////// lgprFull = tnxbPrev.getLogProb() * lgprH * lgprO; - if (OUTPUT_VERYNOISY) { + if (OUTPUT_VERYNOISY) { boost::mutex::scoped_lock lock1(mutexHmmParanoiaLock); //fprintf(stderr," TO: "); h.write(stderr); fprintf(stderr,"\n"); cout<<" "<<tnxbPrev.getId()<<" ==("<<tnxbPrev.getLogProb().toInt()<<"*"<<lgprH.toInt()<<"*"<<lgprO.toInt()<<"="<<lgprFull.toInt()<<")==> "<<h<<"\n"; @@ -420,7 +420,7 @@ void HMM<MH,MO,X,B>::each ( const typename MO::RandVarType& o, Beam<LogProb,X,IB // Incorporate into trellis... btn.tryAdd ( x, IB(i,mh.setBackDat(h)), lgprFull ); // if(OUTPUT_VERYNOISY) -// fprintf ( stderr," (X_t-1:[e^%0.6f] * H:e^%0.6f * O:e^%0.6f = X_t:[e^%0.6f])\n", +// fprintf ( stderr," (X_t-1:[e^%0.6f] * H:e^%0.6f * O:e^%0.6f = X_t:[e^%0.6f])\n", // float(aatnTrellis.get(frameLast-1,i).getLogProb().toInt())/100.0, // float(lgprH.toInt())/100.0, // float(lgprO.toInt())/100.0, @@ -656,7 +656,7 @@ std::list<string> HMM<MH,MO,X,B>::getMLS(const X& xLast) const { //// sprintf(tmp,"HYPOTH %04d> ", fr-1); //// string tString(tmp); //// tString += - string tString = + string tString = //// aatnTrellis.get(fr,iBest).getId().getString() + " " + aatnTrellis.get(fr,iBest).getBackData().getString() //// + "\n" @@ -697,7 +697,7 @@ template <class MH, class MO, class X, class B> void HMM<MH,MO,X,B>::writeCurr ( FILE* pf, int f=-1 ) const { if ( -1==f ) f=frameLast; if ( 0<=f && f<=frameLast ) - for ( int i=0; i<BEAM_WIDTH; i++ ) + for ( int i=0; i<BEAM_WIDTH; i++ ) if(!(aatnTrellis.get(f,i).getLogProb() == LogProb())){ fprintf(pf,"at f=%04d b=%04d: ",f,i); String str; str<<aatnTrellis.get(f,i).getId(); //.write(pf); @@ -721,7 +721,7 @@ void HMM<MH,MO,X,B>::writeCurrSum ( FILE* pf, int f=-1 ) const { if ( 0<=f && f<=frameLast ) { LogProb sum = 0.0; LogProb logtop = 0.0; - for ( int i=0; i<BEAM_WIDTH; i++ ) + for ( int i=0; i<BEAM_WIDTH; i++ ) if(!(aatnTrellis.get(f,i).getLogProb() == LogProb())){ if(i==0) { logtop=aatnTrellis.get(f,i).getLogProb(); } LogProb big1 = sum - logtop; @@ -741,7 +741,7 @@ void HMM<MH,MO,X,B>::writeCurrEntropy ( FILE* pf, int f=-1 ) const { if ( 0<=f && f<=frameLast ) { LogProb logh = 0.0; LogProb logtop = 0.0; - for ( int i=0; i<BEAM_WIDTH; i++ ) + for ( int i=0; i<BEAM_WIDTH; i++ ) if(!(aatnTrellis.get(f,i).getLogProb() == LogProb())){ if(i==0) { logtop=aatnTrellis.get(f,i).getLogProb(); } LogProb big1 = logh - logtop; @@ -768,12 +768,12 @@ void HMM<MH,MO,X,B>::writeCurrDepths ( FILE* pf, int f=-1 ) const { Array<int> depths = Array<int>(); Array<LogProb> logprobs = Array<LogProb>(); double avgdepth = 0.0; - for ( int i=0; i<BEAM_WIDTH; i++ ) + for ( int i=0; i<BEAM_WIDTH; i++ ) if(!(aatnTrellis.get(f,i).getLogProb() == LogProb())){ if(i==0) { logtop=aatnTrellis.get(f,i).getLogProb(); } logprobs.set(i) = aatnTrellis.get(f,i).getLogProb(); - + // loop over values in S node to find lowest meaningful depth for ( int j=0; j<aatnTrellis.get(f,i).getId().first.getSize(); j++) { // store the depth, if it's equal to G_BOT/G_BOT @@ -900,7 +900,7 @@ int HMM<MH,MO,X,B>::getBeamUsed ( int f=-1 ) const { if ( -1==f ) f=frameLast; int ctr=0; if ( 0<=f && f<=frameLast ) - for ( int i=0; i<BEAM_WIDTH; i++ ) + for ( int i=0; i<BEAM_WIDTH; i++ ) if(!(aatnTrellis.get(f,i).getLogProb() == LogProb())){ ctr++; } diff --git a/contrib/synlm/hhmm/rvtl/include/nl-hmmloop.h b/contrib/synlm/hhmm/rvtl/include/nl-hmmloop.h index c476b4271..a8b8d5f27 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-hmmloop.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-hmmloop.h @@ -348,7 +348,7 @@ const TrellNode<S,B>& HMMLoop<MY,MX,S,B>::update ( const typename MX::RandVarTyp //modX.getProb(o,modY.setTrellDat(ashpiQueue.getTop().first,ashpiQueue.getTop().second)); if ( ashpiQueue.getSize() > 0 ) { S s ( ashpiQueue.getTop().second ); - ////S s; modY.setTrellDat(s,ashpiQueue.getTop().second); + ////S s; modY.setTrellDat(s,ashpiQueue.getTop().second); bFull |= btn.tryAdd ( s, IB(ashpiQueue.getTop().first,B(ashpiQueue.getTop().second)), ashpiQueue.getTop().third ); ////cerr<<ashpiQueue.getSize()<<" queue elems A "<<ashpiQueue.getTop()<<"\n"; ////cerr<<"/-----A-----\\\n"<<ashpiQueue<<"\\-----A-----/\n"; diff --git a/contrib/synlm/hhmm/rvtl/include/nl-linsep.h b/contrib/synlm/hhmm/rvtl/include/nl-linsep.h index ac3ef3312..5c644a0fb 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-linsep.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-linsep.h @@ -90,8 +90,8 @@ class Vector : public X { Vector<X> operator- ( ElementType d ) const { Vector<X> vO; for(uint i=0;i<SIZE;i++) vO[i] = X::get(i)-d; return vO; } friend Vector<X> operator* ( ElementType d, const Vector<X>& v ) { Vector<X> vO; for(uint i=0;i<SIZE;i++) vO[i] = d*v[i]; return vO; } friend Vector<X> operator/ ( ElementType d, const Vector<X>& v ) { Vector<X> vO; for(uint i=0;i<SIZE;i++) vO[i] = d/v[i]; return vO; } - friend Vector<X> operator+ ( ElementType d, const Vector<X>& v ) { Vector<X> vO; for(uint i=0;i<SIZE;i++) vO[i] = d+v[i]; return vO; } - friend Vector<X> operator- ( ElementType d, const Vector<X>& v ) { Vector<X> vO; for(uint i=0;i<SIZE;i++) vO[i] = d-v[i]; return vO; } + friend Vector<X> operator+ ( ElementType d, const Vector<X>& v ) { Vector<X> vO; for(uint i=0;i<SIZE;i++) vO[i] = d+v[i]; return vO; } + friend Vector<X> operator- ( ElementType d, const Vector<X>& v ) { Vector<X> vO; for(uint i=0;i<SIZE;i++) vO[i] = d-v[i]; return vO; } Vector<X>& operator*= ( ElementType d ) { for(uint i=0;i<SIZE;i++) X::set(i)*=d; return *this; } Vector<X>& operator/= ( ElementType d ) { for(uint i=0;i<SIZE;i++) X::set(i)/=d; return *this; } Vector<X>& operator+= ( ElementType d ) { for(uint i=0;i<SIZE;i++) X::set(i)+=d; return *this; } diff --git a/contrib/synlm/hhmm/rvtl/include/nl-mixture.h b/contrib/synlm/hhmm/rvtl/include/nl-mixture.h index 2da5aacb2..3a88bea81 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-mixture.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-mixture.h @@ -97,7 +97,7 @@ class Mixture3DModel : public Generic2DModel<Y,X,Prob> { // //////////////////////////////////////////////////////////////////////////////// -template <template <class MY> class M,class Y,class C> +template <template <class MY> class M,class Y,class C> class TrainableMixture2DModel : public Mixture2DModel<M,Y,C> { // private: // LogPDFVal logpdfPrevDataAvg; @@ -110,7 +110,7 @@ class TrainableMixture2DModel : public Mixture2DModel<M,Y,C> { }; //////////////////////////////////////// -template <template <class MY> class M,class Y,class C> +template <template <class MY> class M,class Y,class C> void TrainableMixture2DModel<M,Y,C>::updateFields ( const List<Joint2DRV<Y,Prob> >& lyp, const PDFVal WEIGHT_LIMIT, bool& bShouldStop ) { LogPDFVal logpdfData = 0.0; CPT1DModel<C,Prob> mprPseudoEmpC; // pseudo-empirical prob marginal @@ -178,7 +178,7 @@ void TrainableMixture2DModel<M,Y,C>::updateFields ( const List<Joint2DRV<Y,Prob> } //////////////////////////////////////// -template <template <class MY> class M,class Y,class C> +template <template <class MY> class M,class Y,class C> void TrainableMixture2DModel<M,Y,C>::train ( List<Joint2DRV<Y,Prob> >& lyp, const int EPOCH_LIMIT, const PDFVal WEIGHT_LIMIT ) { // Normalize model... @@ -204,7 +204,7 @@ void TrainableMixture2DModel<M,Y,C>::train ( List<Joint2DRV<Y,Prob> >& lyp, cons //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// -template <template <class MY> class M,class Y,class X,class C> +template <template <class MY> class M,class Y,class X,class C> class TrainableMixture3DModel : public Generic2DModel<Y,X,C> { private: string sId; @@ -225,7 +225,7 @@ class TrainableMixture3DModel : public Generic2DModel<Y,X,C> { }; //////////////////////////////////////// -template <template <class MY> class M,class Y,class X,class C> +template <template <class MY> class M,class Y,class X,class C> void TrainableMixture3DModel<M,Y,X,C>::train ( const int EPOCH_LIMIT, const PDFVal WEIGHT_LIMIT ) { // Update each subphone from list... int ctr = 0; @@ -237,7 +237,7 @@ void TrainableMixture3DModel<M,Y,X,C>::train ( const int EPOCH_LIMIT, const PDFV } //////////////////////////////////////// -template <template <class MY> class M,class Y,class X,class C> +template <template <class MY> class M,class Y,class X,class C> void TrainableMixture3DModel<M,Y,X,C>::train ( const List<Joint3DRV<X,Y,Prob> >& lxyp, const int EPOCH_LIMIT, const PDFVal WEIGHT_LIMIT ) { // Chop list into phone-specific sub-lists... ListedObject<Joint3DRV<X,Y,Prob> >* pxyp; @@ -248,7 +248,7 @@ void TrainableMixture3DModel<M,Y,X,C>::train ( const List<Joint3DRV<X,Y,Prob> >& } //////////////////////////////////////// -template <template <class MY> class M,class Y,class X,class C> +template <template <class MY> class M,class Y,class X,class C> bool TrainableMixture3DModel<M,Y,X,C>::readData ( char* as[], int numFields ) { if ( /*as[0]!=sId+"dat" ||*/ numFields!=3 ) return false; alyp.set(X(as[1])).add() = Joint2DRV<Y,Prob>(Y(as[2]),Prob(1.0)); @@ -256,7 +256,7 @@ bool TrainableMixture3DModel<M,Y,X,C>::readData ( char* as[], int numFields ) { } //////////////////////////////////////// -template <template <class MY> class M,class Y,class X,class C> +template <template <class MY> class M,class Y,class X,class C> void TrainableMixture3DModel<M,Y,X,C>::writeFields ( FILE* pf, string sPref ) { X x; for ( bool b=x.setFirst(); b; b=x.setNext() ) { am.get(x).writeFields(pf,sPref+" "+x.getString()); diff --git a/contrib/synlm/hhmm/rvtl/include/nl-modelfile.h b/contrib/synlm/hhmm/rvtl/include/nl-modelfile.h index dc6bec487..8b9730659 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-modelfile.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-modelfile.h @@ -37,7 +37,7 @@ void processModelFilePtr ( FILE* pf, bool rF(Array<char*>&) ) { int i=0; int numFields=0; int c=' '; int line=1; CONSUME_ALL(pf,c,WHITESPACE(c),line); // Get to first record while ( c!=EOF ) { // For each record - if ( c=='#' ) CONSUME_ALL(pf, c, c!='\n' && c!='\0', line ) ; // If comment, consume + if ( c=='#' ) CONSUME_ALL(pf, c, c!='\n' && c!='\0', line ) ; // If comment, consume else { // If no comment, Array<char*> aps(100); String psBuff(1000); @@ -49,7 +49,7 @@ void processModelFilePtr ( FILE* pf, bool rF(Array<char*>&) ) { if (!z) break; aps[i]=z; } - + if ( !rF(aps) ) // Try to process fields, else complain fprintf( stderr, "\nERROR: %d %d-arg %s in line %d\n\n", numFields, aps.size(), aps[0], line); } @@ -75,7 +75,7 @@ void processModelSocket ( const int tSockfd, int& c, bool rF(Array<char*>&) ) { int i=0; int numFields=0; int line=1; CONSUME_ALL_SOCKET(tSockfd,c,WHITESPACE(c),line); // Get to first record while ( c!='\0' && c!='\5' ) { // For each record - if ( c=='#' ) CONSUME_ALL_SOCKET(tSockfd, c, (c!='\n' && c!='\0' && c!='\5'), line ) ; // If comment, consume + if ( c=='#' ) CONSUME_ALL_SOCKET(tSockfd, c, (c!='\n' && c!='\0' && c!='\5'), line ) ; // If comment, consume else { // If no comment, Array<char*> aps(100); String psBuff(1000); @@ -88,7 +88,7 @@ void processModelSocket ( const int tSockfd, int& c, bool rF(Array<char*>&) ) { if (!z) break; aps[i]=z; } - + if ( !rF(aps) ) // Try to process fields, else complain fprintf( stderr, "\nERROR: %d-arg %s in line %d\n\n", numFields, aps[0], line); } @@ -97,7 +97,7 @@ void processModelSocket ( const int tSockfd, int& c, bool rF(Array<char*>&) ) { } void processModelSocket ( const int tSockfd, bool rF(Array<char*>&) ) { - int c=' '; + int c=' '; processModelSocket ( tSockfd, c, rF ); } diff --git a/contrib/synlm/hhmm/rvtl/include/nl-oblidtree.h b/contrib/synlm/hhmm/rvtl/include/nl-oblidtree.h index 24c82e313..d5bfd5c8e 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-oblidtree.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-oblidtree.h @@ -80,12 +80,12 @@ class binuint { // Input / output methods... friend StringInput operator>> ( StringInput si, binuint& i ) { if(si==NULL) return si; - i.b=0; + i.b=0; for ( char c=si[0]; '0'<=c && c<='1'; ++si,c=si[0]) { i.b=i.b*2+c-'0'; } return si; } - friend ostream& operator<< ( ostream& os, binuint i ) { for(int e=uint(log2(i.b));e>=0;e--)os <<((i.b>>e)%2); return os; } - friend String& operator<< ( String& str, binuint i ) { for(int e=uint(log2(i.b));e>=0;e--)str<<((i.b>>e)%2); return str; } + friend ostream& operator<< ( ostream& os, binuint i ) { for(int e=uint(log2(i.b));e>=0;e--)os <<((i.b>>e)%2); return os; } + friend String& operator<< ( String& str, binuint i ) { for(int e=uint(log2(i.b));e>=0;e--)str<<((i.b>>e)%2); return str; } }; //////////////////////////////////////////////////////////////////////////////// diff --git a/contrib/synlm/hhmm/rvtl/include/nl-prob.h b/contrib/synlm/hhmm/rvtl/include/nl-prob.h index 76cf2fb57..03211404b 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-prob.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-prob.h @@ -43,7 +43,7 @@ class Prob { Prob ( ) { gVal = 0.0; } Prob (double d) { gVal = d; } Prob (const char* ps) { gVal = atof(ps); } - + operator double() const { return gVal; } double toDouble() const { return gVal; } Prob& operator+= ( const Prob p ) { gVal += p.gVal; return *this; } @@ -54,7 +54,7 @@ class Prob { friend ostream& operator<< ( ostream& os, const Prob& pr ) { return os<<pr.toDouble(); } friend String& operator<< ( String& str, const Prob& pr ) { return str<<pr.toDouble(); } friend pair<StringInput,Prob*> operator>> ( StringInput si, Prob& n ) { return pair<StringInput,Prob*>(si,&n); } - friend StringInput operator>> ( pair<StringInput,Prob*> si_n, const char* psDlm ) { + friend StringInput operator>> ( pair<StringInput,Prob*> si_n, const char* psDlm ) { double d=0.0; StringInput si=si_n.first>>d>>psDlm; *si_n.second=Prob(d); return si; } }; @@ -129,7 +129,7 @@ class LogProb : public Id<int> { friend ostream& operator<< ( ostream& os, const LogProb& lp ) { return os<<lp.toInt(); } friend String& operator<< ( String& str, const LogProb& lp ) { return str<<lp.toInt(); } friend pair<StringInput,LogProb*> operator>> ( StringInput si, LogProb& n ) { return pair<StringInput,LogProb*>(si,&n); } - friend StringInput operator>> ( pair<StringInput,LogProb*> si_n, const char* psDlm ) { + friend StringInput operator>> ( pair<StringInput,LogProb*> si_n, const char* psDlm ) { double d=0.0; StringInput si=si_n.first>>d>>psDlm; *si_n.second=LogProb(d); return si; } }; diff --git a/contrib/synlm/hhmm/rvtl/include/nl-probmodel.h b/contrib/synlm/hhmm/rvtl/include/nl-probmodel.h index 2dcff7b30..2b0a0281c 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-probmodel.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-probmodel.h @@ -33,7 +33,7 @@ // //////////////////////////////////////////////////////////////////////////////// -template<class Y,class P> +template<class Y,class P> class Generic1DModel { public: typedef Y RVType; @@ -45,7 +45,7 @@ class Generic1DModel { //////////////////////////////////////////////////////////// -template<class Y,class X1,class P> +template<class Y,class X1,class P> class Generic2DModel { public: typedef Y RVType; @@ -60,7 +60,7 @@ class Generic2DModel { //////////////////////////////////////////////////////////// -template<class Y,class X1,class X2,class P> +template<class Y,class X1,class X2,class P> class Generic3DModel { public: typedef Y RVType; @@ -76,7 +76,7 @@ class Generic3DModel { //////////////////////////////////////////////////////////// -template<class Y,class X1,class X2,class X3,class P> +template<class Y,class X1,class X2,class X3,class P> class Generic4DModel { public: typedef Y RVType; @@ -93,7 +93,7 @@ class Generic4DModel { //////////////////////////////////////////////////////////// -template<class Y,class X1,class X2,class X3,class X4,class P> +template<class Y,class X1,class X2,class X3,class X4,class P> class Generic5DModel { public: typedef Y RVType; @@ -111,7 +111,7 @@ class Generic5DModel { //////////////////////////////////////////////////////////// -template<class Y,class X1,class X2,class X3,class X4,class X5,class P> +template<class Y,class X1,class X2,class X3,class X4,class X5,class P> class Generic6DModel { public: typedef Y RVType; @@ -130,7 +130,7 @@ class Generic6DModel { //////////////////////////////////////////////////////////// -template<class Y,class X1,class X2,class X3,class X4,class X5,class X6,class P> +template<class Y,class X1,class X2,class X3,class X4,class X5,class X6,class P> class Generic7DModel { public: typedef Y RVType; @@ -302,7 +302,7 @@ class Modeled5DRV : public M::RVType { const typename M::Dep2Type& x2, const typename M::Dep3Type& x3, const typename M::Dep4Type& x4 ) const { return m.getProb(*this,x1,x2,x3,x4); } - + }; /////////////////////////////////////////////////////////////////////////////// @@ -346,7 +346,7 @@ class Modeled6DRV : public M::RVType { const typename M::Dep3Type& x3, const typename M::Dep4Type& x4, const typename M::Dep5Type& x5 ) const { return m.getProb(*this,x1,x2,x3,x4,x5); } - + }; /////////////////////////////////////////////////////////////////////////////// @@ -395,7 +395,7 @@ class Modeled7DRV : public M::RVType { const typename M::Dep4Type& x4, const typename M::Dep5Type& x5, const typename M::Dep6Type& x6 ) const { return m.getProb(*this,x1,x2,x3,x4,x5,x6); } - + }; /////////////////////////////////////////////////////////////////////////////// diff --git a/contrib/synlm/hhmm/rvtl/include/nl-racpt.h b/contrib/synlm/hhmm/rvtl/include/nl-racpt.h index 5d1502f1f..342e86de2 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-racpt.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-racpt.h @@ -42,7 +42,7 @@ class GenericRACPTModel : public SimpleHash<K,P> { return ( SimpleHash<K,P>::contains(k) ); } -/* +/* P getProb ( const IterVal& ikyp, const K& k ) const { if ( ikyp.iter.first == ikyp.iter.second ) { cerr<<"ERROR: no iterator to fix probability: "<<k<<endl; return P(); } return ( ikyp.iter.first->second ); @@ -91,7 +91,7 @@ class GenericRACPTModel : public SimpleHash<K,P> { for ( typename HKP::const_iterator ik=HKP::begin(); ik!=HKP::end(); ik++ ) { K k=ik->first; os << psId<<" "<<k<<" = "<<getProb(k).toDouble()<<endl; - + // IterVal y; // for ( bool b=setFirst(y,k); b; b=setNext(y,k) ) // os<<psId<<" "<<k<<" : "<<y<<" = "<<getProb(y,k).toDouble()<<"\n"; @@ -110,14 +110,14 @@ class GenericRACPTModel : public SimpleHash<K,P> { friend pair<StringInput,GenericRACPTModel<K,P>*> operator>> ( StringInput si, GenericRACPTModel<K,P>& m ) { return pair<StringInput,GenericRACPTModel<K,P>*>(si,&m); } - + friend StringInput operator>> ( pair<StringInput,GenericRACPTModel<K,P>*> delimbuff, const char* psD ) { - K k; - StringInput si,si2,si3; + K k; + StringInput si,si2,si3; GenericRACPTModel<K,P>& m = *delimbuff.second; si=delimbuff.first; if ( si==NULL ) return si; - + // Kill the colon since we're treating the whole thing as the condition char * str = si.c_str(); char * p = strchr(str, ':'); @@ -125,17 +125,17 @@ class GenericRACPTModel : public SimpleHash<K,P> { p[0] = ' '; } si=str; - while((si2=si>>" ")!=NULL)si=si2; + while((si2=si>>" ")!=NULL)si=si2; si=si>>k>>" "; - while((si2=si>>" ")!=NULL)si=si2; + while((si2=si>>" ")!=NULL)si=si2; si=si>>"= "; - while((si2=si>>" ")!=NULL)si=si2; + while((si2=si>>" ")!=NULL)si=si2; return (si!=NULL) ? si>>m.setProb(k)>>psD : si; } }; -template<class Y, class P> +template<class Y, class P> class RandAccCPT1DModel : public GenericRACPTModel<MapKey1D<Y>,P> { public: // typedef typename GenericCPTModel<Y,MapKey1D<Unit>,P>::IterVal IterVal; @@ -170,7 +170,7 @@ P& setProb ( const Y& y ) { //////////////////// -template<class Y, class X1, class P> +template<class Y, class X1, class P> class RandAccCPT2DModel : public GenericRACPTModel<MapKey2D<X1,Y>,P> { public: @@ -187,7 +187,7 @@ class RandAccCPT2DModel : public GenericRACPTModel<MapKey2D<X1,Y>,P> { P getProb ( const Y& y, const X1& x1 ) const { return GenericRACPTModel<MapKey2D<X1,Y>,P>::getProb ( MapKey2D<X1,Y>(x1,y) ); } - + /* P& setProb ( const Y& y, const X1& x1 ) { cerr << "setProb called on racpt2d" << endl; @@ -199,7 +199,7 @@ class RandAccCPT2DModel : public GenericRACPTModel<MapKey2D<X1,Y>,P> { //////////////////// -template<class Y, class X1, class X2, class P> +template<class Y, class X1, class X2, class P> class RandAccCPT3DModel : public GenericRACPTModel<MapKey3D<X1,X2,Y>,P> { public: @@ -219,7 +219,7 @@ class RandAccCPT3DModel : public GenericRACPTModel<MapKey3D<X1,X2,Y>,P> { /* //////////////////// -template<class Y, class X1, class X2, class X3, class P> +template<class Y, class X1, class X2, class X3, class P> class CPT4DModel : public GenericCPTModel<Y,MapKey3D<X1,X2,X3>,P> { public: typedef typename GenericCPTModel<Y,MapKey3D<X1,X2,X3>,P>::IterVal IterVal; @@ -256,7 +256,7 @@ class CPT4DModel : public GenericCPTModel<Y,MapKey3D<X1,X2,X3>,P> { //////////////////// -template<class Y, class X1, class X2, class X3, class X4, class P> +template<class Y, class X1, class X2, class X3, class X4, class P> class CPT5DModel : public GenericCPTModel<Y,MapKey4D<X1,X2,X3,X4>,P> { public: typedef typename GenericCPTModel<Y,MapKey4D<X1,X2,X3,X4>,P>::IterVal IterVal; @@ -293,7 +293,7 @@ class CPT5DModel : public GenericCPTModel<Y,MapKey4D<X1,X2,X3,X4>,P> { //////////////////// -template<class Y, class X1, class X2, class X3, class X4, class X5, class P> +template<class Y, class X1, class X2, class X3, class X4, class X5, class P> class RACPT6DModel : public GenericCPTModel<Y,MapKey5D<X1,X2,X3,X4,X5>,P> { public: typedef typename GenericCPTModel<Y,MapKey5D<X1,X2,X3,X4,X5>,P>::IterVal IterVal; diff --git a/contrib/synlm/hhmm/rvtl/include/nl-randvar.h b/contrib/synlm/hhmm/rvtl/include/nl-randvar.h index 66cc0b8f2..b4caa2bde 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-randvar.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-randvar.h @@ -129,7 +129,7 @@ class DiscreteDomainRV : public Id<T> { friend pair<StringInput,DiscreteDomainRV<T,domain>*> operator>> ( const StringInput ps, DiscreteDomainRV<T,domain>& rv ) { return pair<StringInput,DiscreteDomainRV<T,domain>*>(ps,&rv); } friend StringInput operator>> ( pair<StringInput,DiscreteDomainRV<T,domain>*> delimbuff, const char* psDlm ) { if (StringInput(NULL)==delimbuff.first) return delimbuff.first; - ////assert(*delimbuff.second<domain.getSize()); + ////assert(*delimbuff.second<domain.getSize()); int j=0; StringInput psIn = delimbuff.first; if(psDlm[0]=='\0') { *delimbuff.second=psIn.c_str(); return psIn+strlen(psIn.c_str()); } @@ -203,7 +203,7 @@ template <class T> const T RefRV<T>::DUMMY; //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// -template<class V1,class V2> +template<class V1,class V2> class Joint2DRV { public: @@ -216,7 +216,7 @@ class Joint2DRV { Joint2DRV ( const V1& v1, const V2& v2 ) { first=v1; second=v2; } // Extraction methods... - size_t getHashKey ( ) const { size_t k=rotLeft(first.getHashKey(),3); k^=second.getHashKey(); + size_t getHashKey ( ) const { size_t k=rotLeft(first.getHashKey(),3); k^=second.getHashKey(); /*fprintf(stderr," (%d) %d ^& %d = %d\n",sizeof(*this),x1.getHashKey(),x2.getHashKey(),k);*/ return k; } bool operator< ( const Joint2DRV<V1,V2>& j ) const { return ( (first<j.first) || (first==j.first && second<j.second) ); } @@ -276,7 +276,7 @@ class DelimitedJoint2DRV : public Joint2DRV<V1,V2> { friend pair<StringInput,DelimitedJoint2DRV<SD1,V1,SD2,V2,SD3>*> operator>> ( StringInput ps, DelimitedJoint2DRV<SD1,V1,SD2,V2,SD3>& rv ) { return pair<StringInput,DelimitedJoint2DRV<SD1,V1,SD2,V2,SD3>*>(ps,&rv); } friend StringInput operator>> ( pair<StringInput,DelimitedJoint2DRV<SD1,V1,SD2,V2,SD3>*> delimbuff, const char* psDlm ) { if (StringInput(NULL)==delimbuff.first) return delimbuff.first; - return ( (SD3[0]=='\0') ? delimbuff.first>>SD1>>delimbuff.second->first>>SD2>>delimbuff.second->second>>psDlm + return ( (SD3[0]=='\0') ? delimbuff.first>>SD1>>delimbuff.second->first>>SD2>>delimbuff.second->second>>psDlm : delimbuff.first>>SD1>>delimbuff.second->first>>SD2>>delimbuff.second->second>>SD3>>psDlm ); } }; @@ -290,7 +290,7 @@ class DelimitedJoint2DRV : public Joint2DRV<V1,V2> { // //////////////////////////////////////////////////////////////////////////////// -template<class V1,class V2,class V3> +template<class V1,class V2,class V3> class Joint3DRV { public: @@ -361,7 +361,7 @@ class DelimitedJoint3DRV : public Joint3DRV<V1,V2,V3> { return pair<StringInput,DelimitedJoint3DRV<SD1,V1,SD2,V2,SD3,V3,SD4>*>(ps,&rv); } friend StringInput operator>> ( pair<StringInput,DelimitedJoint3DRV<SD1,V1,SD2,V2,SD3,V3,SD4>*> delimbuff, const char* psDlm ) { if (StringInput(NULL)==delimbuff.first) return delimbuff.first; - return ( (SD4[0]=='\0') ? delimbuff.first>>SD1>>delimbuff.second->first>>SD2>>delimbuff.second->second>>SD3>>delimbuff.second->third>>psDlm + return ( (SD4[0]=='\0') ? delimbuff.first>>SD1>>delimbuff.second->first>>SD2>>delimbuff.second->second>>SD3>>delimbuff.second->third>>psDlm : delimbuff.first>>SD1>>delimbuff.second->first>>SD2>>delimbuff.second->second>>SD3>>delimbuff.second->third>>SD4>>psDlm ); } }; @@ -453,7 +453,7 @@ class DelimitedJoint4DRV : public Joint4DRV<V1,V2,V3,V4> { // //////////////////////////////////////////////////////////////////////////////// -template <int I, class T> +template <int I, class T> class JointArrayRV { private: // Data members... @@ -491,7 +491,7 @@ class JointArrayRV { //////////////////////////////////////////////////////////////////////////////// -template <int I, char* SD, class T> +template <int I, char* SD, class T> class DelimitedJointArrayRV : public JointArrayRV<I,T> { public: @@ -569,7 +569,7 @@ class History { /* void read ( char* ps, const ReaderContext& rc=ReaderContext() ) { char* psT; for(int i=0;i<N;i++){char* z=strtok_r((0==i)?ps:NULL,";",&psT); assert(z); at.set(i).read(z);} } //at.set(i).read(strtok_r((0==i)?ps:NULL,";",&psT)); } - */ + */ friend ostream& operator<< ( ostream& os, const History<N,T>& a ) { for(int i=0;i<N;i++)os<<((i==0)?"":";")<<a.getBack(i); return os; } friend pair<StringInput,History<N,T>*> operator>> ( StringInput ps, History<N,T>& a ) { return pair<StringInput,History<N,T>*>(ps,&a); } diff --git a/contrib/synlm/hhmm/rvtl/include/nl-safeids.h b/contrib/synlm/hhmm/rvtl/include/nl-safeids.h index 50837c366..c5f9dcb67 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-safeids.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-safeids.h @@ -30,7 +30,7 @@ #include "nl-stream.h" #include <iostream> -using namespace std; +using namespace std; //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// @@ -39,7 +39,7 @@ using namespace std; // //////////////////////////////////////////////////////////////////////////////// -template <int I, class T> +template <int I, class T> class StaticSafeArray { private: // Data members... @@ -84,7 +84,7 @@ class StaticSafeArray { //////////////////////////////////////////////////////////////////////////////// -template <int I, char* SD, class T> +template <int I, char* SD, class T> class DelimitedStaticSafeArray : public StaticSafeArray<I,T> { public: DelimitedStaticSafeArray ( ) : StaticSafeArray<I,T>() { } @@ -349,7 +349,7 @@ class SafeArray2D { // Extraction methods... const T& get (const X1& x,const X2& y) const { assert(at!=NULL); assert(x.toInt()>=0); assert(x.toInt()<xSize); - assert(y.toInt()>=0); + assert(y.toInt()>=0); //this assert failed when compile without -DNDEBUG (needed for debugging). Have to figure out why before adding this assert back in //assert(y.toInt()<ySize); return at[x.toInt()*ySize + y.toInt()];} @@ -423,7 +423,7 @@ class SafeArray4D { { delete[] at; wSize=sat.wSize; xSize=sat.xSize; ySize=sat.ySize; zSize=sat.zSize; at=new T[wSize*xSize*ySize*zSize]; for(int i=0;i<wSize*xSize*ySize*zSize;i++) at[i]=sat.at[i]; return *this; } - void init (int w,int x,int y,int z) + void init (int w,int x,int y,int z) { delete[] at; wSize=w; xSize=x; ySize=y; zSize=z; at=new T[w*x*y*z]; } void init (int w,int x,int y,int z,const T& t) { delete[] at; wSize=w; xSize=x; ySize=y; zSize=z; at=new T[w*x*y*z]; @@ -472,7 +472,7 @@ class SafeArray5D { { delete[] at; vSize=sat.vSize; wSize=sat.wSize; xSize=sat.xSize; ySize=sat.ySize; zSize=sat.zSize; at=new T[vSize*wSize*xSize*ySize*zSize]; for(int i=0;i<vSize*wSize*xSize*ySize*zSize;i++) at[i]=sat.at[i]; return *this; } - void init(int v,int w,int x,int y,int z) + void init(int v,int w,int x,int y,int z) { delete[] at; vSize=v; wSize=w; xSize=x; ySize=y; zSize=z; at=new T[v*w*x*y*z]; } void init(int v,int w,int x,int y,int z,const T& t) { delete[] at; vSize=v; wSize=w; xSize=x; ySize=y; zSize=z; at=new T[v*w*x*y*z]; diff --git a/contrib/synlm/hhmm/rvtl/include/nl-stream.h b/contrib/synlm/hhmm/rvtl/include/nl-stream.h index 8f743e12b..ee3b641fb 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-stream.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-stream.h @@ -86,7 +86,7 @@ class IStream { friend ostream& operator<< ( ostream& os, const IStream& is ) { return os<<is.iIndex<<","<<is.psrc<<","<<*is.psrc; } // Match single char... - friend IStream operator>> ( IStream is, char& c ) { + friend IStream operator>> ( IStream is, char& c ) { // Propagate fail... if (IStream()==is) return IStream(); c=is.get(is.iIndex); @@ -106,7 +106,7 @@ class IStream { // Match anything else followed by zero-terminated string delimiter... template<class X> friend pair<IStream,X*> operator>> ( IStream is, X& x ) { return pair<IStream,X*>(is,&x); } - template<class X> friend IStream operator>> ( pair<IStream,X*> is_x, const char* psDlm ) { + template<class X> friend IStream operator>> ( pair<IStream,X*> is_x, const char* psDlm ) { IStream& is = is_x.first; X& x = *is_x.second; // Propagate fail... @@ -129,7 +129,7 @@ class IStream { } // Match integer followed by zero-terminated string delimiter... - friend IStream operator>> ( pair<IStream,int*> is_x, const char* psDlm ) { + friend IStream operator>> ( pair<IStream,int*> is_x, const char* psDlm ) { IStream& is = is_x.first; int& x = *is_x.second; // Propagate fail... @@ -151,7 +151,7 @@ class IStream { } // Match unsigned int followed by zero-terminated string delimiter... - friend IStream operator>> ( pair<IStream,unsigned int*> is_x, const char* psDlm ) { + friend IStream operator>> ( pair<IStream,unsigned int*> is_x, const char* psDlm ) { IStream& is = is_x.first; unsigned int& x = *is_x.second; // Propagate fail... @@ -173,7 +173,7 @@ class IStream { } // Match float followed by zero-terminated string delimiter... - friend IStream operator>> ( pair<IStream,float*> is_x, const char* psDlm ) { + friend IStream operator>> ( pair<IStream,float*> is_x, const char* psDlm ) { IStream& is = is_x.first; float& x = *is_x.second; // Propagate fail... @@ -195,7 +195,7 @@ class IStream { } // Match double followed by zero-terminated string delimiter... - friend IStream operator>> ( pair<IStream,double*> is_x, const char* psDlm ) { + friend IStream operator>> ( pair<IStream,double*> is_x, const char* psDlm ) { IStream& is = is_x.first; double& x = *is_x.second; // Propagate fail... @@ -217,7 +217,7 @@ class IStream { } // Match void pointer followed by zero-terminated string delimiter... - friend IStream operator>> ( pair<IStream,void**> is_x, const char* psDlm ) { + friend IStream operator>> ( pair<IStream,void**> is_x, const char* psDlm ) { IStream& is = is_x.first; // Propagate fail... if (IStream()==is) return IStream(); diff --git a/contrib/synlm/hhmm/rvtl/include/nl-string.h b/contrib/synlm/hhmm/rvtl/include/nl-string.h index 1a7fc34ae..73e831539 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-string.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-string.h @@ -68,13 +68,13 @@ class StringInput { friend StringInput operator>> ( StringInput psIn, const char* psDlm ) { if (StringInput(NULL)==psIn) return psIn; int i; - for (i=0; psIn[i]!='\0' && psDlm[i]!='\0'; i++) + for (i=0; psIn[i]!='\0' && psDlm[i]!='\0'; i++) if(psIn[i]!=psDlm[i]) return StringInput(NULL); //psIn; return (psDlm[i]!='\0') ? StringInput(NULL) : (psIn[i]!='\0') ? psIn+i : SI_EOS; } friend pair<StringInput,int*> operator>> ( StringInput ps, int& n ) { return pair<StringInput,int*>(ps,&n); } - friend StringInput operator>> ( pair<StringInput,int*> delimbuff, const char* psDlm ) { + friend StringInput operator>> ( pair<StringInput,int*> delimbuff, const char* psDlm ) { if (StringInput(NULL)==delimbuff.first) return delimbuff.first; ///int i; for(i=0;psIn[i]!='\0';i++) if(psIn[i]==psDlm[i]) return psIn; return psIn+i; int j=0; @@ -90,7 +90,7 @@ class StringInput { } friend pair<StringInput,unsigned int*> operator>> ( StringInput ps, unsigned int& n ) { return pair<StringInput,unsigned int*>(ps,&n); } - friend StringInput operator>> ( pair<StringInput,unsigned int*> delimbuff, const char* psDlm ) { + friend StringInput operator>> ( pair<StringInput,unsigned int*> delimbuff, const char* psDlm ) { if (StringInput(NULL)==delimbuff.first) return delimbuff.first; ///int i; for(i=0;psIn[i]!='\0';i++) if(psIn[i]==psDlm[i]) return psIn; return psIn+i; int j=0; @@ -106,7 +106,7 @@ class StringInput { } friend pair<StringInput,double*> operator>> ( StringInput ps, double& d ) { return pair<StringInput,double*>(ps,&d); } - friend StringInput operator>> ( pair<StringInput,double*> delimbuff, const char* psDlm ) { + friend StringInput operator>> ( pair<StringInput,double*> delimbuff, const char* psDlm ) { if (StringInput(NULL)==delimbuff.first) return delimbuff.first; ///int i; for(i=0;psIn[i]!='\0';i++) if(psIn[i]==psDlm[i]) return psIn; return psIn+i; int j=0; @@ -191,7 +191,7 @@ class String : public Array<char> { friend pair<StringInput,String*> operator>> ( const StringInput ps, String& s ) { return pair<StringInput,String*>(ps,&s); } friend StringInput operator>> ( pair<StringInput,String*> delimbuff, const char* psDlm ) { if (StringInput(NULL)==delimbuff.first) return delimbuff.first; - ////assert(*delimbuff.second<domain.getSize()); + ////assert(*delimbuff.second<domain.getSize()); int j=0; StringInput psIn = delimbuff.first; if(psDlm[0]=='\0') { *delimbuff.second=String(psIn.c_str()); return psIn+strlen(psIn.c_str()); } diff --git a/contrib/synlm/hhmm/rvtl/include/nl-stringindex.h b/contrib/synlm/hhmm/rvtl/include/nl-stringindex.h index 22931f081..933aba23d 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-stringindex.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-stringindex.h @@ -38,7 +38,7 @@ class StringIndex{ map <string, int> msi; map <int, string> mis; int maxIndex; - + public: // Constructor / destructor methods... diff --git a/contrib/synlm/hhmm/rvtl/include/nl-tetrahex.h b/contrib/synlm/hhmm/rvtl/include/nl-tetrahex.h index d77e4f471..60746bd53 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-tetrahex.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-tetrahex.h @@ -22,7 +22,7 @@ /////////////////////////////////////////////////////////////////////////////// /*********************************************** - * nl-tetrahex.h + * nl-tetrahex.h * a little header with some base conversion stuff * so that we can represent base 16, 32 or 64 with * one character. diff --git a/contrib/synlm/hhmm/rvtl/include/nl-timer.h b/contrib/synlm/hhmm/rvtl/include/nl-timer.h index 3fa7c5387..f6d08c992 100644 --- a/contrib/synlm/hhmm/rvtl/include/nl-timer.h +++ b/contrib/synlm/hhmm/rvtl/include/nl-timer.h @@ -41,7 +41,7 @@ class Timer { } double elapsed ( ) { // in milliseconds. return (double(kept.tv_sec)*1000.0 + double(kept.tv_usec)/1000.0); - //struct timeval end; gettimeofday(&end,NULL); + //struct timeval end; gettimeofday(&end,NULL); //double beg_time_s = (double) beg.tv_sec + (double) ((double)beg.tv_usec / 1000000.0); //double end_time_s = (double) end.tv_sec + (double) ((double)end.tv_usec / 1000000.0); //return ( (end_time_s - beg_time_s) * 1000.0 ); |