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


C++ SuffixArray::Create方法代码示例

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


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

示例1: main

int main(int argc, char* argv[]) {
  // handle parameters
  string query;
  string fileNameSuffix;
  string fileNameSource;
  int loadFlag = false;
  int saveFlag = false;
  int createFlag = false;
  int queryFlag = false;
  int stdioFlag = false;  // receive requests from STDIN, respond to STDOUT
  string info = "usage: biconcor\n\t[--load model-file]\n\t[--save model-file]\n\t[--create corpus]\n\t[--query string]\n\t[--stdio]\n";
  while(1) {
    static struct option long_options[] = {
      {"load", required_argument, 0, 'l'},
      {"save", required_argument, 0, 's'},
      {"create", required_argument, 0, 'c'},
      {"query", required_argument, 0, 'q'},
      {"stdio", no_argument, 0, 'i'},
      {0, 0, 0, 0}
    };
    int option_index = 0;
    int c = getopt_long (argc, argv, "l:s:c:q:i", long_options, &option_index);
    if (c == -1) break;
    switch (c) {
    case 'l':
      fileNameSuffix = string(optarg);
      loadFlag = true;
      break;
    case 's':
      fileNameSuffix = string(optarg);
      saveFlag = true;
      break;
    case 'c':
      fileNameSource = string(optarg);
      createFlag = true;
      break;
    case 'q':
      query = string(optarg);
      queryFlag = true;
      break;
    case 'i':
      stdioFlag = true;
      break;
    default:
      cerr << info;
      exit(1);
    }
  }
  if (stdioFlag) {
    queryFlag = true;
  }

  // check if parameter settings are legal
  if (saveFlag && !createFlag) {
    cerr << "error: cannot save without creating\n" << info;
    exit(1);
  }
  if (saveFlag && loadFlag) {
    cerr << "error: cannot load and save at the same time\n" << info;
    exit(1);
  }
  if (!loadFlag && !createFlag) {
    cerr << "error: neither load or create - i have no info!\n" << info;
    exit(1);
  }

  // do your thing
  if (createFlag) {
    cerr << "will create\n";
    cerr << "corpus is in " << fileNameSource << endl;
    suffixArray.Create( fileNameSource );
    if (saveFlag) {
      suffixArray.Save( fileNameSuffix );
      cerr << "will save in " << fileNameSuffix << endl;
    }
  }
  if (loadFlag) {
    cerr << "will load from " << fileNameSuffix << endl;
    suffixArray.Load( fileNameSuffix );
  }
  if (stdioFlag) {
    while(true) {
      string query;
      if (getline(cin, query, '\n').eof()) {
        return 0;
      }
      cout << lookup( query ) << endl;
    }
  } 
  else if (queryFlag) {
    cout << lookup( query ) << endl;
  }
  return 0;
}
开发者ID:840462307cn,项目名称:mosesdecoder,代码行数:94,代码来源:phrase-lookup.cpp

示例2: main


//.........这里部分代码省略.........
            break;
        case 'e':
            max_example = atoi(optarg);
            break;
        case 'p':
            prettyFlag = true;
            break;
        case 'h':
            htmlFlag = true;
            break;
        case 'i':
            stdioFlag = true;
            break;
        default:
            cerr << info;
            exit(1);
        }
    }
    if (stdioFlag) {
        queryFlag = true;
    }

    // check if parameter settings are legal
    if (saveFlag && !createFlag) {
        cerr << "error: cannot save without creating\n" << info;
        exit(1);
    }
    if (saveFlag && loadFlag) {
        cerr << "error: cannot load and save at the same time\n" << info;
        exit(1);
    }
    if (!loadFlag && !createFlag) {
        cerr << "error: neither load or create - i have no info!\n" << info;
        exit(1);
    }
    if (createFlag && (fileNameTarget == "" || fileNameAlignment == "")) {
        cerr << "error: i have no target corpus or alignment\n" << info;
        exit(1);
    }

    // do your thing
    SuffixArray suffixArray;
    TargetCorpus targetCorpus;
    Alignment alignment;
    if (createFlag) {
        cerr << "will create\n";
        cerr << "source corpus is in " << fileNameSource << endl;
        suffixArray.Create( fileNameSource );
        cerr << "target corpus is in " << fileNameTarget << endl;
        targetCorpus.Create( fileNameTarget );
        cerr << "alignment is in " << fileNameAlignment << endl;
        alignment.Create( fileNameAlignment );
        if (saveFlag) {
            suffixArray.Save( fileNameSuffix );
            targetCorpus.Save( fileNameSuffix );
            alignment.Save( fileNameSuffix );
            cerr << "will save in " << fileNameSuffix << endl;
        }
    }
    if (loadFlag) {
        cerr << "will load from " << fileNameSuffix << endl;
        suffixArray.Load( fileNameSuffix );
        targetCorpus.Load( fileNameSuffix );
        alignment.Load( fileNameSuffix );
    }
    if (stdioFlag) {
        cout << "-|||- BICONCOR START -|||-" << endl << flush;
        while(true) {
            string query;
            if (getline(cin, query, '\n').eof()) {
                return 0;
            }
            vector< string > queryString = alignment.Tokenize( query.c_str() );
            PhrasePairCollection ppCollection( &suffixArray, &targetCorpus, &alignment, max_translation, max_example );
            int total = ppCollection.GetCollection( queryString );
            cout << "TOTAL: " << total << endl;
            if (htmlFlag) {
                ppCollection.PrintHTML();
            }
            else {
                ppCollection.Print(prettyFlag);
            }
            cout << "-|||- BICONCOR END -|||-" << endl << flush;
        }
    }
    else if (queryFlag) {
        cerr << "query is " << query << endl;
        vector< string > queryString = alignment.Tokenize( query.c_str() );
        PhrasePairCollection ppCollection( &suffixArray, &targetCorpus, &alignment, max_translation, max_example );
        ppCollection.GetCollection( queryString );
        if (htmlFlag) {
            ppCollection.PrintHTML();
        }
        else {
            ppCollection.Print(prettyFlag);
        }
    }

    return 0;
}
开发者ID:crazydreamer,项目名称:moses-online,代码行数:101,代码来源:biconcor.cpp

示例3: main

int main(int argc, char* argv[]) 
{
	// handle parameters
	string query;
	string fileNameSuffix;
	string fileNameSource;
	string fileNameTarget = "";
	string fileNameAlignment = "";
	int loadFlag = false;
	int saveFlag = false;
	int createFlag = false;
	int queryFlag = false;
	int htmlFlag = false;
	string info = "usage: suffix-query\n\t[--load file]\n\t[--save file]\n\t[--create source-corpus]\n\t[--query string]\n\t[--target target-corpus]\n\t[--alignment file]\n";
	while(1) {
		static struct option long_options[] = {
			{"load", required_argument, 0, 'l'},
			{"save", required_argument, 0, 's'},
			{"create", required_argument, 0, 'c'},
			{"query", required_argument, 0, 'q'},
			{"target", required_argument, 0, 't'},
			{"alignment", required_argument, 0, 'a'},
			{"html", no_argument, &htmlFlag, 0},
			{0, 0, 0, 0}
		};
		int option_index = 0;
		int c = getopt_long (argc, argv, "l:s:c:q:t:a:h", long_options, &option_index);
		if (c == -1) break;
		switch (c) {
			case 'l':
				fileNameSuffix = string(optarg);
				loadFlag = true;
				break;
			case 't':
				fileNameTarget = string(optarg);
				break;
			case 'a':
				fileNameAlignment = string(optarg);
				break;
			case 's':
				fileNameSuffix = string(optarg);
				saveFlag = true;
				break;
			case 'c':
				fileNameSource = string(optarg);
				createFlag = true;
				break;
			case 'q':
				query = string(optarg);
				queryFlag = true;
				break;
			default:
				cerr << info;
				exit(1);
		}
	}		
  
	// check if parameter settings are legal
	if (saveFlag && !createFlag) {
		cerr << "error: cannot save without creating\n" << info;
		exit(1);
	}
	if (saveFlag && loadFlag) {
		cerr << "error: cannot load and save at the same time\n" << info;
		exit(1);
	}
	if (!loadFlag && !createFlag) {
		cerr << "error: neither load or create - i have no info!\n" << info;
		exit(1);
	}
	if (createFlag && (fileNameTarget == "" || fileNameAlignment == "")) {
		cerr << "error: i have no target corpus or alignment\n" << info;
		exit(1);		
	}

	// do your thing
	SuffixArray suffixArray;
	TargetCorpus targetCorpus;
	Alignment alignment;
	if (createFlag) {
		cerr << "will create\n";
		cerr << "source corpus is in " << fileNameSource << endl;
		suffixArray.Create( fileNameSource );
		cerr << "target corpus is in " << fileNameTarget << endl;
		targetCorpus.Create( fileNameTarget );
		cerr << "alignment is in " << fileNameAlignment << endl;
		alignment.Create( fileNameAlignment );
		if (saveFlag) {
			suffixArray.Save( fileNameSuffix );
			targetCorpus.Save( fileNameSuffix );
			alignment.Save( fileNameSuffix );
			cerr << "will save in " << fileNameSuffix << endl;
		}
	}
	if (loadFlag) {
		cerr << "will load from " << fileNameSuffix << endl;
		suffixArray.Load( fileNameSuffix );
		targetCorpus.Load( fileNameSuffix );
		alignment.Load( fileNameSuffix );
	}
//.........这里部分代码省略.........
开发者ID:obo,项目名称:Moses-Extensions-at-UFAL,代码行数:101,代码来源:biconcor.cpp


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