Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
  int retval = 0;
  int i;

  for (i = 1; argv[i]; i++) {
    if (strcmp(argv[i], "-v") == 0)
      tstflags |= tst_verbatim;
    else if (strcmp(argv[i], "-a") == 0)
      tstflags |= tst_abort;
    else
      usage(1);
  }
#if HAVE_OPEN_C
  tstflags |= tst_verbatim;
#endif

  retval |= test_alloc();
  retval |= test_lock();
  retval |= test_strdupcat();
  retval |= test_sprintf("%s.%s", "foo", "bar");
  retval |= test_strlst();
  retval |= test_vectors();
  retval |= test_auto();

  return retval;
}
Ejemplo n.º 2
0
//****************************************对抽取的语料库按类别进行分类****************************************
void corpus_category(string filename_path, string path_read, string path_write) //参数1:文件名列表路径 参数2:读取文件的目录 参数3:写入文件的目录
{

	string file_name;    //存储读取的各个文件的名字
	ifstream read_filename(filename_path);  //从LIST.TXT读取文件名
	ofstream sports(path_write+"sports.txt");//属于sport类的存放在sport.txt文件中
	ofstream house(path_write+"house.txt");
	ofstream it(path_write+"it.txt");
	ofstream test_2008(path_write+"2008.txt");
	ofstream news(path_write+"news.txt");
	ofstream yule(path_write+"yule.txt");
	ofstream business(path_write+"business.txt");
	ofstream travel(path_write+"travel.txt");
	ofstream mil_news(path_write+"mil.news.txt");
	ofstream women(path_write+"women.txt");
	ofstream health(path_write+"health.txt");
	ofstream test_auto(path_write+"auto.txt");
	ofstream cul(path_write+"cul.txt");
	ofstream learning(path_write+"learning.txt");
	ofstream test_else(path_write+"else.txt");
	string path_in, str_line,cut_str;//path_in:存放读文件路径 str_line:读取的一行文件 cut_str:存放截取的字符串
	string::size_type pos1, pos2;
	int number = 0;
	while (getline(read_filename, file_name))
	{
		number++;
		cout << number << endl;
		path_in = path_read + file_name;
		ifstream infile(path_in);
		while (getline(infile, str_line))              //读取各个文件的每一行字符串
		{
			pos1 = 0;
			pos2 = str_line.find("####");
			cut_str = str_line.substr(pos1, pos2 - pos1);
			if (string(cut_str) == string("sports"))         //字符串匹配  是否为sports类
			{
				sports << str_line << endl;                  //如果是sports类就把该行输出到sports.txt文件
			}
			else if (cut_str == "house")
			{
				house << str_line << endl;
			}
			else if (cut_str == "it")
			{
				it << str_line << endl;
			}
			else if (cut_str == "2008")
			{
				test_2008 << str_line << endl;
			}
			else if (cut_str == "news")
			{
				news << str_line << endl;
			}
			else if (cut_str == "yule")
			{
				yule << str_line << endl;
			}
			else if (cut_str == "business")
			{
				business << str_line << endl;
			}
			else if (cut_str == "travel")
			{
				travel << str_line << endl;
			}
			else if (cut_str == "mil.news")
			{
				mil_news << str_line << endl;
			}
			else if (cut_str == "women")
			{
				women << str_line << endl;
			}
			else if (cut_str == "health")
			{
				health << str_line << endl;
			}
			else if (cut_str == "auto")
			{
				test_auto << str_line << endl;
			}
			else if (cut_str == "cul")
			{
				cul << str_line << endl;
			}
			else if (cut_str == "learning")
			{
				learning << str_line << endl;
			}
			else
			{
				test_else << str_line << endl;
			}
		}
		infile.close();   //每次结束都得关闭文件.
	}
}