void generalInit(ECString path) { struct rlimit core_limits; core_limits.rlim_cur = 0; core_limits.rlim_max = 0; setrlimit( RLIMIT_CORE, &core_limits ); struct rlimit stack_limits; stack_limits.rlim_cur = 0; stack_limits.rlim_max = 0; getrlimit( RLIMIT_STACK, &stack_limits ); if (stack_limits.rlim_cur < stack_limits.rlim_max) { stack_limits.rlim_cur = stack_limits.rlim_max; setrlimit( RLIMIT_STACK, &stack_limits ); } if (!endsWith(path, "/")) { path += "/"; } Term::init( path ); readHeadInfo(path); InputTree::init(); UnitRules* ur = new UnitRules; ur->readData(path); Bchart::unitRules = ur; Bchart::readTermProbs(path); MeChart::init(path); Bchart::setPosStarts(); ChartBase::midFactor = (1.0 - (.3684 *ChartBase::endFactor))/(1.0 - .3684); if(Feature::isLM or Feature::useExtraConditioning) ClassRule::readCRules(path); }
void Controller::GameEventProcessor::processEvent(Model *m, sf::Event e){ if(e.type == sf::Event::MouseButtonPressed){ std::vector <Unit*> vec = m->getDesk().getUnits(); Unit * unit = vec.front(); UnitRules rules; std::vector<MapShape*> tmp = rules.getHex(m->getDesk(),unit->getHome()); // unit->getHome()->lightUp(); for(std::vector <MapShape*>::iterator it = tmp.begin(); it != tmp.end(); ++it) (*it)->lightUp(); lighted = tmp; } }
void generalInit(ECString path) { struct rlimit core_limits; core_limits.rlim_cur = 0; core_limits.rlim_max = 0; setrlimit( RLIMIT_CORE, &core_limits ); struct rlimit stack_limits; stack_limits.rlim_cur = 0; stack_limits.rlim_max = 0; getrlimit( RLIMIT_STACK, &stack_limits ); if (stack_limits.rlim_cur < stack_limits.rlim_max) { stack_limits.rlim_cur = stack_limits.rlim_max; setrlimit( RLIMIT_STACK, &stack_limits ); } // load locale settings from the environment setlocale(LC_ALL, ""); path = sanitizePath(path); Term::init( path ); readHeadInfo(path); InputTree::init(); UnitRules* ur = new UnitRules; ur->readData(path); Bchart::unitRules = ur; Bchart::readTermProbs(path); MeChart::init(path); Bchart::setPosStarts(); ChartBase::midFactor = (1.0 - (.3684 *ChartBase::endFactor))/(1.0 - .3684); if(Feature::isLM or Feature::useExtraConditioning) ClassRule::readCRules(path); }
int main(int argc, char *argv[]) { ECArgs args( argc, argv ); assert(args.nargs() == 1); ECString path(args.arg(0)); cerr << "At start of pHsgt" << endl; for(int n = 0 ; n < MAXNUMNTS ; n++) numTerm[n] = 0; Term::init( path ); readHeadInfo(path); int sentenceCount = 0; ECString s1lex("^^"); ECString s1nm("S1"); int s1Int = Term::get(s1nm)->toInt(); UnitRules ur; ur.init(); while(cin) { //if(sentenceCount > 4000) break; if(sentenceCount%10000 == 0) cerr << sentenceCount << endl; InputTree parse; cin >> parse; //cerr << parse << endl; if(!cin) break; if(parse.length() == 0) break; EcSPairs wtList; parse.make(wtList); InputTree* par; par = &parse; addWwData(par); incrWordData(s1Int, s1lex); ur.gatherData(par); sentenceCount++; } ECString resultsString(path); resultsString += "pSgT.txt"; ofstream resultsStream(resultsString.c_str()); assert(resultsStream); int numWords = 0; resultsStream << " \n"; //leave space for number of words; resultsStream.precision(3); ECString lastWord; int wordFreq = 0; WordMap::iterator wmi = wordMap.begin(); resultsStream << wordMap.size() << "\n\n"; for( ; wmi != wordMap.end() ; wmi++) { ECString w = (*wmi).first; resultsStream << w << "\t"; PosD& posd = (*wmi).second; PosD::iterator pdi = posd.begin(); int count = 0; for( ; pdi != posd.end(); pdi++) { int posInt = (*pdi).first; int c = (*pdi).second; count += c; float p = (float)c/(float)numTerm[posInt]; resultsStream << posInt << " " << p << " "; } resultsStream << "| " << count << "\n"; } ur.setData(path); return 1; }