本文整理汇总了C++中Samu类的典型用法代码示例。如果您正苦于以下问题:C++ Samu类的具体用法?C++ Samu怎么用?C++ Samu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Samu类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main ( int argc, char **argv )
{
#ifndef Q_LOOKUP_TABLE
std::string samuImage {"samu.soul.txt"};
std::fstream samuFile ( samuImage, std::ios_base::in );
if ( samuFile )
samu.load ( samuFile );
#endif
struct sigaction sa;
sa.sa_handler = save_samu;
sigemptyset ( &sa.sa_mask );
sa.sa_flags = SA_RESTART;
sigaction ( SIGINT, &sa, NULL );
sigaction ( SIGTERM, &sa, NULL );
sigaction ( SIGKILL, &sa, NULL );
sigaction ( SIGHUP, &sa, NULL );
// Do not remove this copyright notice!
std::cerr << "This program is Isaac, the son of Samu Bátfai."
<< std::endl
<< "Copyright (C) 2015 Norbert Bátfai"
<< std::endl
<< "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>"
<< std::endl
<< "This is free software: you are free to change and redistribute it."
<< std::endl
<< "There is NO WARRANTY, to the extent permitted by law."
<< std::endl
<< std::endl;
std::map<std::string, std::vector<std::string>> tests
{
{
"sentences of the paper [1]",
{
"A rare black squirrel has become a regular visitor to a suburban garden",
"This is a car",
"This car is mine",
"I have a little car",
"The sky is blue",
"The little brown bear has eaten all of the honey",
"I love Samu"
}
},
{
"introduce myself",
{
"Who are you",
"I am a robot",
"What is your name",
"My name is Judah",
"Where do you live",
"I live in Debrecen",
"How old are you",
"I am one year old",
"Where were you born"
"I was born is Debrecen"
"What is your favourite colour"
"My favourite colours are red, white and green"
}
}
};
std::map<std::string, SPOTriplets> test_triplets
{
{
"introduce myself",
{
{ "who", "are", "you" },
{ "i", "am", "robot" },
{"what", "is", "name"},
{"name", "is", "Judah"},
{"you", "live", "where"},
{"I", "live", "Debrecen"},
{"you", "are", "how"},
{"i", "am", "one"},
{"you", "born", "where"},
{"I", "born", "Debrecen"}
}
}
};
int j {0};
int N_e {25};
std::string training_file = samu.get_training_file();
samu.set_training_file ( "bbe" );
double prev_mbrel {0};
int mbrelc {0};
#ifdef SUPER_OR_REMOTE_COMP
//for ( int ii {0}; samu.run() && ii < 1000 + 4000 + 5000 + 4000 + 1000; ++ii )
for ( int ii {0}; samu.run() /*&& ii < 50000*/; ++ii )
#else
//.........这里部分代码省略.........
示例2: main
int main ( int argc, char **argv )
{
#ifndef Q_LOOKUP_TABLE
std::string samuImage {"samu.image.txt"};
std::fstream samuFile ( samuImage, std::ios_base::in );
if ( samuFile )
samu.load ( samuFile );
#endif
struct sigaction sa;
sa.sa_handler = save_samu;
sigemptyset ( &sa.sa_mask );
sa.sa_flags = SA_RESTART;
sigaction ( SIGINT, &sa, NULL );
sigaction ( SIGTERM, &sa, NULL );
sigaction ( SIGKILL, &sa, NULL );
sigaction ( SIGHUP, &sa, NULL );
// Do not remove this copyright notice!
std::cout << "This program is Isaac, the son of Samu Bátfai."
<< std::endl
<< "Copyright (C) 2015 Norbert Bátfai"
<< std::endl
<< "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>"
<< std::endl
<< "This is free software: you are free to change and redistribute it."
<< std::endl
<< "There is NO WARRANTY, to the extent permitted by law."
<< std::endl
<< std::endl;
std::cout << "The prenatal development phase has started."
<< std::endl;
//
std::cout << "The prenatal development phase has finished."
<< std::endl;
std::string test[] =
{
"A rare black squirrel has become a regular visitor to a suburban garden",
"This is a car",
"This car is mine",
"I have a little car",
"The sky is blue",
"The little brown bear has eaten all of the honey",
"I love Samu"
};
int j {0};
for ( ; samu.run(); )
{
double sum {0.0};
if ( samu.sleep() )
{
for ( int i {0}; i<7; ++i )
{
samu << test[i];
sum += samu.reward();
}
std::cerr << "###### " << ++j << "-th iter " << sum << std::endl;
}
}
return 0;
}
示例3: save_samu
void save_samu ( int sig )
{
#ifndef Q_LOOKUP_TABLE
std::string samuImage {"samu.image.txt"};
samu.save ( samuImage );
#endif
samu.halt();
exit ( 0 );
}
示例4: to_samu
double to_samu ( int channel, std::string &msg )
{
double r {0.0};
try
{
samu.sentence ( channel, msg );
r = samu.reward();
}
catch ( const char* err )
{
std::cerr << err << std::endl;
}
return r;
}
示例5: save_samu
void save_samu ( int sig )
{
if ( halted )
return;
halted = true;
#ifndef Q_LOOKUP_TABLE
std::string samuImage {"samu.soul.txt"};
samu.save ( samuImage );
#endif
samu.halt();
exit ( 0 );
}
示例6: read_cache
double read_cache ( std::string & key, int &cnt, int &brel )
{
double sum {0.0};
int count {0};
for ( auto const & t: cache[key] )
{
if ( !samu.sleep() )
break;
if ( count++ >= samuHasAlreadyLearned )
break;
SPOTriplets tv;
tv.push_back ( t );
sum += to_samu ( 12, tv );
++cnt;
brel += samu.get_brel();
}
return sum;
}