当前位置: 首页>>代码示例>>C++>>正文


C++ Sequence::getRowSize方法代码示例

本文整理汇总了C++中Sequence::getRowSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Sequence::getRowSize方法的具体用法?C++ Sequence::getRowSize怎么用?C++ Sequence::getRowSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sequence的用法示例。


在下文中一共展示了Sequence::getRowSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: extfeature

void Cnflearn::extfeature()
{
   FILE *fp = NULL;
   if ((fp = fopen(this->corpus.c_str(),"r")) == NULL)
   {
      fprintf (stderr,"Couln't open %s\n", this->corpus.c_str());
      exit (1);
   }
   Sequence sq;
   sq.setColSize(this->sqcolsize);
   sq.setAllocSize(this->sqallocsize);
   sq.setArraySize(this->sqarraysize);
   sq.init();
   this->instance = 0;
   while(feof(fp) == 0)
   {
      MyUtil::sqread(fp,&sq,CNF_BUFSIZE);
      if (sq.getRowSize() == 0)
      {
         continue;
      }
      this->extlabel(&sq);
      this->extract(&sq);
      this->instance++;
      sq.clear();
   }
   fclose(fp);
}
开发者ID:NweZinOo,项目名称:cnf,代码行数:28,代码来源:cnflearn.cpp

示例2: learn

void Cnflearn::learn(unsigned int iter, unsigned int reg)
{
   if (!this->valid)
   {
      fprintf (stderr, "It's not initialized\n");
      exit(1);
   }
   AllocMemdiscard cache(this->cachesize);
   Sequence sq;
   sq.setColSize(this->sqcolsize);
   sq.setAllocSize(this->sqallocsize);
   sq.setArraySize(this->sqarraysize);
   sq.init();
   int t = 0;
   for (unsigned int i = 0; i < iter; i++)
   {
      FILE *fp = NULL;
      if ((fp = fopen(this->corpus.c_str(), "r")) == NULL)
      {
         fprintf (stderr, "Couldn't open %s\n", this->corpus.c_str());
         exit (1);
      }
      while (feof(fp) == 0)
      {
         MyUtil::sqread(fp, &sq, CNF_BUFSIZE);
         if (sq.getRowSize() == 0)
         {
            continue;
         }
         this->decay(t++);
         this->update(&sq, &cache, reg);
         sq.clear();
         cache.reset();
      }
      fclose(fp);
      this->lreport(i);
   }
}
开发者ID:NweZinOo,项目名称:cnf,代码行数:38,代码来源:cnflearn.cpp

示例3: main

int main (int argc, char **argv)
{
   if (argc < 5)
   {
      fprintf (stderr, "template inputfile.gz colsize bound\n");
      exit (1);
   }
   FILE *fp = NULL;
   if ((fp = fopen(*(argv+1),"r")) == NULL)
   {
      fprintf (stderr, "Couldn't open %s\n", *(argv+1));
      exit (1);
   }
   PoolAlloc ac(256, 1000000);
   std::list<tmpl*> tmpls;
   char buf[BUFSIZE];
   while (fgets(buf, BUFSIZE, fp) != NULL)
   {
      MyUtil::chomp(buf);
      if (MyUtil::IsCommentOut(buf))
      {
         continue;
      }
      tmpl *t = new tmpl(buf, &ac);
      tmpls.push_back(t);
   }

   int fd = open(*(argv+2), O_RDONLY);
   if (fd < 0)
   {
      fprintf (stderr, "Couldn't open %s\n",*(argv+2));
      exit (1);
   }
   gzFile input = gzdopen(fd, GZ_MODE);
   if (input == NULL)
   {
      fprintf (stderr, "failed to gzdopen\n");
      exit (1);
   }

   int colsize = 0;
   sscanf (*(argv+3),"%d",&colsize);
   int bound = 0;
   sscanf (*(argv+4),"%d",&bound);

   Sequence sq;
   sq.setColSize(colsize);
   sq.init();

   Dic features(&ac, CountUp);

   while (gzgets(input, buf, BUFSIZE) != NULL)
   {
      MyUtil::chomp(buf);
      if (MyUtil::IsEOS(buf))
      {
         int size = (int)sq.getRowSize();
         std::list<tmpl*>::iterator it = tmpls.begin();
         for (; it != tmpls.end(); it++)
         {
            for (int i = 0; i < size; i++)
            {
               char *feature = (*it)->expand(&sq,i);
               //fprintf(stdout, "%s\n",feature);
               features.insert(feature);
               ac.release(feature);
            }
         }
         sq.clear();
         continue;
      }
      sq.push(buf);
   }

   nodeptr nil = features.getnil();
   for (int i = HASHSIZE-1; i >= 0; i--)
   {
      nodeptr *p = features.table+i;
      if (*p != nil)
      {
         recalldump(nil, (*p)->left, bound);
         recalldump(nil, (*p)->right, bound);
      }
   }

   if (gzclose(input) != Z_OK)
   {
      fprintf (stderr,"gzclose failed\n");
      exit (1);
   }
   return 0;
}
开发者ID:NweZinOo,项目名称:cnf,代码行数:92,代码来源:dictest.cpp


注:本文中的Sequence::getRowSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。