本文整理汇总了C++中Word类的典型用法代码示例。如果您正苦于以下问题:C++ Word类的具体用法?C++ Word怎么用?C++ Word使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Word类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_unfold
void test_unfold( )
{
typedef IntLabeledGraph Graph;
typedef Graph::edge_type edge_type;
typedef Graph::vertex_type vertex_type;
Graph F;
int o = F.newVertex( );
Word x1( 1 );
Word x2( 2 );
for( int i=0 ; i<5; ++i ) {
Word w = Word::randomWord( 2 , 3 );
addLoop( F , o , w.begin( ) , w.end( ) );
}
set< int > candidates;
candidates.insert( o );
list< FoldDetails< vertex_type , edge_type > > details;
fold( F , candidates , &details );
if( F.getVertices( ).size( )>1 )
return;
pair< bool , list< edge_type > > path = trace_path( F , o , x2.begin( ) , x2.end( ) );
liftup( F , o , path.second , details.begin( ) , details.end( ) );
}
示例2: main
int main( )
{
FPGroup G;
cout << "Enter nilpotentcy class first then group ";
int NilpotentcyClass;
cin >> NilpotentcyClass;
Chars errMsg = cin >> G;
if (errMsg.length()>0)
return 1;
NilpotentGroup ng(G.namesOfGenerators(),
NilpotentcyClass,makeVectorOf(G.getRelators()));
ng.initialize();
VectorOf<Word> vw;
Word w;
for (int i=1;true;i++){
cout << endl << "Enter the "<<i<<" generator of subgroup"<< endl;
cout << "Empty word to finish: ";
w = G.readWord(cin,errMsg);
if (w.length()==0)
break;
if (errMsg.length()>0)
return 1;
vw.append(w);
}
SGOfNilpotentGroup sg(ng,vw);
sg.initBasis();
sg.printBasis(cout);
cout << "The Hirsch number :" << sg.theHirschNumber() << endl;
cout << "Index in parent group :" << sg.index() << endl;
cout << "Is Trivial :" << sg.isTrivial() << endl;
cout << "Is Central :" << sg.isCentral() << endl;
cout << "Is normal :" << sg.isNormal() << endl;
cout << "Is abelian :" << sg.isAbelian() << endl;
cout << "Subgroup class :" << sg.subgroupClass() << endl;
cout << "Generators of normal closure :" << endl;
vw = sg.normalClosureGens();
for (int i=0;i<vw.length();i++){
G.printWord(cout,vw[i]);
cout << endl;
}
PresentationForSNG sgp = sg.makePresentation();
cout << "Presentation of subgroup :" << endl;
sgp.print(cout);
cout << endl << "Enter the word :";
errMsg = "";
w = G.readWord(cin,errMsg);
if (errMsg.length()>0){
cout << errMsg;
return 1;
}
cout << endl << "Does subgroup contain the word :" << sg.contains(w) << endl;
PolyWord result;
if (sg.decompose(ng.decompose(w),result))
cout << "Decomposition in sg basis :" << sg.asDecomposition(result);
else
cout << "Subgroup does not contain this word";
}
示例3: GetWordID
// get wordID_t index for word represented as string
wordID_t Vocab::GetWordID(const std::string& word_str,
const FactorDirection& direction, const FactorList& factors, bool isNonTerminal)
{
// get id for factored string
Word word;
word.CreateFromString( direction, factors, word_str, isNonTerminal);
return GetWordID( word);
}
示例4: right
int Group::right (int v, const Word& word)
{
int g = v;
for (unsigned t=0; t<word.size(); ++t) {
g = right(g, word[word.size() -t -1]);
}
return g;
}
示例5: main6
//测试word的相关操作
int main6() {
Word *word = new Word("wordfdsafds");
RedisProxy redisProxy("localhost", 6379);
redisProxy.addWord(word);
word = redisProxy.getWord(word->getId());
std::cout << word->getId() << " " << word->getName();
return 0;
}
示例6: greedyReduce
Word GAConjProblemForORGroupSolver::greedyReduce( const OneRelatorGroup& group , const Word& word )
{
Word w = word;
w = w.cyclicallyReduce( );
while( oneGreedyReduce( group , w ) );
return w;
}
示例7: MakeWord
static Word MakeWord(string text)
{
FactorCollection &factorCollection = FactorCollection::Instance();
const Factor* f = factorCollection.AddFactor(Input,0,text);
Word w;
w.SetFactor(0,f);
return w;
}
示例8: transform
bool operator > (Word w1, Word w2) {
string w1word = w1.getWord();
string w2word = w2.getWord();
transform(w1word.begin(), w1word.end(), w1word.begin(), ::toupper);
transform(w2word.begin(), w2word.end(), w2word.begin(), ::toupper);
return (w1word > w2word);
}
示例9: reduce
Word TheGrigorchukGroupAlgorithms::reduce( const Word& w )
{
Word result;
for( Word::const_iterator w_it=w.begin( ) ; w_it!=w.end( ) ; ++w_it )
push_back( result , *w_it );
return result;
}
示例10: int2word
Word int2word(int g)
{
Word result;
while (g) {
result.push_back((g % 10) - 1);
g /= 10;
}
return result;
}
示例11: VERBOSE
void GlobalLexicalModel::Load()
{
FactorCollection &factorCollection = FactorCollection::Instance();
const std::string& factorDelimiter = StaticData::Instance().GetFactorDelimiter();
VERBOSE(2, "Loading global lexical model from file " << m_filePath << endl);
m_inputFactors = FactorMask(m_inputFactorsVec);
m_outputFactors = FactorMask(m_outputFactorsVec);
InputFileStream inFile(m_filePath);
// reading in data one line at a time
size_t lineNum = 0;
string line;
while(getline(inFile, line)) {
++lineNum;
vector<string> token = Tokenize<string>(line, " ");
if (token.size() != 3) { // format checking
UTIL_THROW2("Syntax error at " << m_filePath << ":" << lineNum << ":" << line);
}
// create the output word
Word *outWord = new Word();
vector<string> factorString = Tokenize( token[0], factorDelimiter );
for (size_t i=0 ; i < m_outputFactorsVec.size() ; i++) {
const FactorDirection& direction = Output;
const FactorType& factorType = m_outputFactorsVec[i];
const Factor* factor = factorCollection.AddFactor( direction, factorType, factorString[i] );
outWord->SetFactor( factorType, factor );
}
// create the input word
Word *inWord = new Word();
factorString = Tokenize( token[1], factorDelimiter );
for (size_t i=0 ; i < m_inputFactorsVec.size() ; i++) {
const FactorDirection& direction = Input;
const FactorType& factorType = m_inputFactorsVec[i];
const Factor* factor = factorCollection.AddFactor( direction, factorType, factorString[i] );
inWord->SetFactor( factorType, factor );
}
// maximum entropy feature score
float score = Scan<float>(token[2]);
// std::cerr << "storing word " << *outWord << " " << *inWord << " " << score << endl;
// store feature in hash
DoubleHash::iterator keyOutWord = m_hash.find( outWord );
if( keyOutWord == m_hash.end() ) {
m_hash[outWord][inWord] = score;
} else { // already have hash for outword, delete the word to avoid leaks
(keyOutWord->second)[inWord] = score;
delete outWord;
}
}
}
示例12: print
void WQueue::print()
{
Word* cur = front;
while (cur != NULL)
{
cout << cur->getData() << " ";
cur = cur->getNext();
}
}
示例13: DisplayS
void TTSQueue::DisplayS()
{
Word * word = header;
while(word != NULL)
{
word->DisplayS();
word = word->next;
}
}
示例14: strcpy
Word Word::operator+(const Word& rhs)
{
char* temp = new char[this->string_length_ + rhs.len() - 1];
strcpy(temp, this->string_);
strcat(temp, rhs.getString());
Word sum(temp);
delete [] temp;
return sum;
}
示例15: TEST_F
//word
TEST_F(Gtest, test_Word) {
std::string name = "wordfdsafds";
Word *word = new Word("wordfdsafds");
RedisProxy redisProxy("localhost", 6379);
redisProxy.addWord(word);
word = redisProxy.getWord(word->getId());
std::cout << word->getId() << " " << word->getName() << std::endl;
EXPECT_EQ(name, word->getName());
}