void HiRes4Engine_Atari::init() { _graphics = new Graphics_v2(*_display); _boot = new DiskImage(); if (!_boot->open(atariDisks[0])) error("Failed to open disk image '%s'", atariDisks[0]); insertDisk(1); loadCommonData(); StreamPtr stream(createReadStream(_boot, 0x06, 0x2)); _strings.verbError = readStringAt(*stream, 0x4f); _strings.nounError = readStringAt(*stream, 0x83); _strings.enterCommand = readStringAt(*stream, 0xa6); stream.reset(createReadStream(_boot, 0x05, 0xb, 0xd7)); _strings_v2.time = readString(*stream, 0xff); stream.reset(createReadStream(_boot, 0x06, 0x7, 0x00, 2)); _strings_v2.saveInsert = readStringAt(*stream, 0x62); _strings_v2.saveReplace = readStringAt(*stream, 0xdd); _strings_v2.restoreInsert = readStringAt(*stream, 0x12a); _strings_v2.restoreReplace = readStringAt(*stream, 0x1b8); _strings.playAgain = readStringAt(*stream, 0x21b); // TODO: restart sequence has "insert side a/b" strings _messageIds.cantGoThere = IDI_HR4_MSG_CANT_GO_THERE; _messageIds.dontUnderstand = IDI_HR4_MSG_DONT_UNDERSTAND; _messageIds.itemDoesntMove = IDI_HR4_MSG_ITEM_DOESNT_MOVE; _messageIds.itemNotHere = IDI_HR4_MSG_ITEM_NOT_HERE; _messageIds.thanksForPlaying = IDI_HR4_MSG_THANKS_FOR_PLAYING; stream.reset(createReadStream(_boot, 0x06, 0xd, 0x12, 2)); loadItemDescriptions(*stream, IDI_HR4_NUM_ITEM_DESCS); stream.reset(createReadStream(_boot, 0x07, 0x1, 0xf4)); loadDroppedItemOffsets(*stream, IDI_HR4_NUM_ITEM_OFFSETS); stream.reset(createReadStream(_boot, 0x08, 0xe, 0xa5, 5)); readCommands(*stream, _roomCommands); stream.reset(createReadStream(_boot, 0x0a, 0x9, 0x00, 3)); readCommands(*stream, _globalCommands); stream.reset(createReadStream(_boot, 0x05, 0x4, 0x00, 3)); loadWords(*stream, _verbs, _priVerbs); stream.reset(createReadStream(_boot, 0x03, 0xb, 0x00, 6)); loadWords(*stream, _nouns, _priNouns); }
void relationRecon(char *fileName) /* Do relationship based reconstruction. */ { char **words; long start, end; struct sqlConnection *conn = sqlConnect(database); struct sqlResult *sr; char **row; FILE *f = mustOpen(fileName, "w"); int lineCount; int i; char query[256]; start = clock1000(); words = loadWords(); end = clock1000(); printf("Time to load words: %4.3f\n", 0.001*(end-start)); start = clock1000(); lineCount = sqlTableSize(conn, "lineSize"); for (i=0; i<lineCount; ++i) { sprintf(query, "select * from lineWords where line = %d", i); sr = sqlQuery(conn, query); while ((row = sqlNextRow(sr)) != NULL) fileOutput(f,words[sqlUnsigned(row[1])]); sqlFreeResult(&sr); } end = clock1000(); printf("Time to relation reconstruct file: %4.3f\n", 0.001*(end-start)); sqlDisconnect(&conn); }
void StandardStopFilter::setParam(const tstring& sParam) { KeyValueParser parser; if (parser.parse(sParam, TokenFilter::PARAM_SEPERATOR, TokenFilter::EQUAL_MARK)) { size_t nWords = 0; string sValue; if (parser.getValue("words", sValue)) { nWords = loadWords(sValue); } else if (parser.getValue("file", sValue)) { nWords = loadFile(sValue); } else { return ; } if (nWords == 0) { FX_LOG(ERROR, "Load stop words: [%s] FAILED.", sValue.c_str()); } else { FX_LOG(INFO, "Loaded [%u] stop words.", (uint32_t)nWords); } } }
RoiGenerator::RoiGenerator() : m_roiCount(0) , m_learnCount(0) , m_learnings("learn.txt",std::ofstream::out) { loadWords(); }
bool Tester::load(time_t initID,bool Random) { if( loadWords(initID,Random) ) { wordList = new WordList(words.size(),configHolder.t_list()); return true; }else { return false; } }
void RoiGenerator::reload() { std::cout << "Reloading Word lists..." << std::endl; m_learnCount = 0; allWords.clear(); words.clear(); loadWords(); }
//这里是lucene分词器实现的最关键的地方 lucene::analysis::Token* next(lucene::analysis::Token* token) { loadWords(); std::wstring currentWord; while (true) { WCHAR ch; // if (bufferIndex >= dataLen) { dataLen = input->read(ioBuffer, 1, LUCENE_IO_BUFFER_SIZE); bufferIndex = 0; } if (dataLen == -1) { if (currentWord.length() == 0) { return NULL; } else { break; } } else { ch = ioBuffer[bufferIndex++]; } //通过这个条件不难看出这里只处理了CJK_UNIFIED_IDEOGRAPHS, //因此会丢掉其它的字符,如它会丢掉LATIN字符和数字 //这也是该lucene分词器的一个限制,您可以在此基础之上完善它, //也很欢迎把您完善的结果反馈给我 if (_CJK) { if (currentWord.length() == 0) { currentWord += ch; } else { //这里实现了正向最大匹配法 std::wstring temp = currentWord; temp += ch; // if (simWords->find(temp) != simWords->end()) { currentWord = temp; } else { bufferIndex--; break; } } } } // token->set(currentWord.c_str(), 0, currentWord.length()); return token; }
/** * Load our default hard-coded words and put them into this database. Save the words we add * so that if the locale changes we can remove those words and re-read in new ones from * the new locale. */ SMKY_STATUS SmkyManufacturerDatabase::loadDefaultData(const LocaleSettings& localeSettings) { std::string fname = localeSettings.findLocalResource(m_settings.readOnlyDataDir + "/smky/DefaultData/manufacturer/", "/man-db-entries"); SMKY_STATUS wStatus = loadWords(fname.c_str(), m_stockManDbWords); g_debug("Loaded %u words from man-db default data for locale '%s' from '%s'. Result: %u", m_stockManDbWords.size(), localeSettings.getFullLocale().c_str(), fname.c_str(), wStatus); return wStatus; }
void hashtest( void ){ hlState_t state; double end, start; hlHashTable_t table = hl_hinit(&state); start = (float)clock()/CLOCKS_PER_SEC; loadWords(&table); end = (float)clock()/CLOCKS_PER_SEC; printf("Inserted, retrieved, and deleted %d objects in %fs - Table size: %d\n", table.c, end - start, hlhprimes[table.s]); }
void Similarity::initialize(boost::shared_ptr<Corpus> ptrInCorp, boost::shared_ptr<Corpus> ptrOutCorp, boost::shared_ptr<XenVocab> ptrVocab) { ptrVoc = ptrVocab; ptrID = ptrInCorp; ptrOOD = ptrOutCorp; loadWords(); computeInDomainTFIDF(); computeOutOfDomainTFIDF(); buildIDVector(); computeOutOfDomainIDF(); computeSimilarity(); }
// TODO - баг - пишет щас что есть id = 49 втф, как? // типо если тупо добавить слово 1 ти пишет херню как так? // баг еще в том что почему то индекмы отрицательные стали - вообще прочекать втф!!! // TODO !!!! забыл добавть колноку - сколько там foriegn keys!!!!! int main(){ std::vector<Word> dictionary; std::cout<<"loading words...\n"; //dictionary.push_back(Word("1")); loadWords(dictionary); std::cout<<"calculation...\n"; calcAllWords(dictionary); std::cout<<"saving to db...\n"; saveToDB(dictionary); system("pause"); return 0; }
int main(int argc, char* argv[]){ int ret; AppContext ctx; ret = parseArgs(argc, argv, ctx); CHECK_RETURN(ret); ret = loadWords(ctx); CHECK_RETURN(ret); ret = process(ctx); return ret; }
SmkyManufacturerDatabase::SmkyManufacturerDatabase(SMKY_LINFO& lingInfo, const Settings& settings) : SmkyDatabase(lingInfo) , m_settings(settings) , m_hunspell(NULL) , m_hunspellSize(0) , m_expectedContactCount(500) , m_lastHunspellResult(NULL) , m_lastHunspellResultCount(0) { g_ManDb = this; std::string fname = m_settings.readOnlyDataDir + "/smky/DefaultData/manufacturer/man-db-entries"; loadWords(fname.c_str(), m_universalWords); g_debug("Loaded %u universal words.", m_universalWords.size()); }
void commaRecon(char *fileName) /* Do comma based reconstruction. */ { char **words; long start, end; struct sqlConnection *conn = sqlConnect(database); struct sqlResult *sr; char **row; FILE *f = mustOpen(fileName, "w"); start = clock1000(); words = loadWords(); end = clock1000(); printf("Time to load words: %4.3f\n", 0.001*(end-start)); start = clock1000(); sr = sqlQuery(conn, "SELECT * from commaLine"); while ((row = sqlNextRow(sr)) != NULL) { int wordCount = sqlUnsigned(row[1]); int i; char *s = row[2],*e; int wordIx; for (i=0; i<wordCount; ++i) { e = strchr(s,','); *e++ = 0; wordIx = sqlUnsigned(s); s = e; fileOutput(f,words[wordIx]); } } end = clock1000(); printf("Time to comma reconstruct file: %4.3f\n", 0.001*(end-start)); sqlDisconnect(&conn); }
void TwitLibs::doTwitLibs() { loadWords(); std::string userName( "" ); std::string passWord( "" ); printf( "Enter twitter username: "******"Enter twitter password: "******"M0732hNbsNWFAt5EI2z8bA" ) ); twitterObj.getOAuth().setConsumerSecret( std::string( "iI6jbNN3rn7tZmOsMvSiWXcYo9e36HzWwpZdEJvh7bs" ) ); /* Step 1: Check if we alredy have OAuth access token from a previous run */ std::string myOAuthAccessTokenKey("85586080-mEQUEMw1tiId6XaC3xW6k0U4C3uQMRHGYWWaP6Qw"); std::string myOAuthAccessTokenSecret("ghtJ0vSe5Z8LYAMurSXjvN2rfEkOxuxIgYMU6lAF138"); std::ifstream oAuthTokenKeyIn; std::ifstream oAuthTokenSecretIn; /* oAuthTokenKeyIn.open( "twitterClient_token_key.txt" ); oAuthTokenSecretIn.open( "twitterClient_token_secret.txt" ); memset( tmpBuf, 0, 1024 ); oAuthTokenKeyIn >> tmpBuf; myOAuthAccessTokenKey = tmpBuf; memset( tmpBuf, 0, 1024 ); oAuthTokenSecretIn >> tmpBuf; myOAuthAccessTokenSecret = tmpBuf; oAuthTokenKeyIn.close(); oAuthTokenSecretIn.close(); */ if( myOAuthAccessTokenKey.size() && myOAuthAccessTokenSecret.size() ) { /* If we already have these keys, then no need to go through auth again */ printf( "\nUsing:\nKey: %s\nSecret: %s\n\n", myOAuthAccessTokenKey.c_str(), myOAuthAccessTokenSecret.c_str() ); twitterObj.getOAuth().setOAuthTokenKey( myOAuthAccessTokenKey ); twitterObj.getOAuth().setOAuthTokenSecret( myOAuthAccessTokenSecret ); } else { /* Step 2: Get request token key and secret */ std::string authUrl; twitterObj.oAuthRequestToken( authUrl ); /* Step 3: Get PIN */ memset( tmpBuf, 0, 1024 ); printf( "\nDo you want to visit twitter.com for PIN (0 for no; 1 for yes): " ); gets( tmpBuf ); tmpStr = tmpBuf; if( std::string::npos != tmpStr.find( "1" ) ) { /* Ask user to visit twitter.com auth page and get PIN */ memset( tmpBuf, 0, 1024 ); printf( "\nPlease visit this link in web browser and authorize this application:\n%s", authUrl.c_str() ); printf( "\nEnter the PIN provided by twitter: " ); gets( tmpBuf ); tmpStr = tmpBuf; twitterObj.getOAuth().setOAuthPin( tmpStr ); } else { /* Else, pass auth url to twitCurl and get it via twitCurl PIN handling */ twitterObj.oAuthHandlePIN( authUrl ); } /* Step 4: Exchange request token with access token */ twitterObj.oAuthAccessToken(); /* Step 5: Now, save this access token key and secret for future use without PIN */ twitterObj.getOAuth().getOAuthTokenKey( myOAuthAccessTokenKey ); twitterObj.getOAuth().getOAuthTokenSecret( myOAuthAccessTokenSecret ); /* Step 6: Save these keys in a file or wherever */ std::ofstream oAuthTokenKeyOut; std::ofstream oAuthTokenSecretOut; oAuthTokenKeyOut.open( "twitterClient_token_key.txt" ); oAuthTokenSecretOut.open( "twitterClient_token_secret.txt" ); oAuthTokenKeyOut.clear(); oAuthTokenSecretOut.clear(); oAuthTokenKeyOut << myOAuthAccessTokenKey.c_str(); oAuthTokenSecretOut << myOAuthAccessTokenSecret.c_str(); oAuthTokenKeyOut.close(); oAuthTokenSecretOut.close(); } /* OAuth flow ends */ /* Account credentials verification */ if( twitterObj.accountVerifyCredGet() ) { twitterObj.getLastWebResponse( replyMsg ); printf( "\ntwitterClient:: twitCurl::accountVerifyCredGet web response:\n%s\n", replyMsg.c_str() ); } else { twitterObj.getLastCurlError( replyMsg ); printf( "\ntwitterClient:: twitCurl::accountVerifyCredGet error:\n%s\n", replyMsg.c_str() ); } /* Post a new status message */ memset( tmpBuf, 0, 1024 ); printf( "\nEnter a new status message: " ); gets( tmpBuf ); tmpStr = tmpBuf; replaceWords(tmpStr); replyMsg = ""; if( twitterObj.statusUpdate( tmpStr ) ) { twitterObj.getLastWebResponse( replyMsg ); //printf( "\ntwitterClient:: twitCurl::statusUpdate web response:\n%s\n", replyMsg.c_str() ); } else { twitterObj.getLastCurlError( replyMsg ); //printf( "\ntwitterClient:: twitCurl::statusUpdate error:\n%s\n", replyMsg.c_str() ); } std::cin.get(); }
void HiRes1Engine::init() { if (Common::File::exists("MYSTHOUS.DSK")) { _files = new Files_DOS33(); if (!static_cast<Files_DOS33 *>(_files)->open("MYSTHOUS.DSK")) error("Failed to open MYSTHOUS.DSK"); } else _files = new Files_Plain(); _graphics = new Graphics_v1(*_display); StreamPtr stream(_files->createReadStream(IDS_HR1_EXE_1)); // Some messages have overrides inside the executable _gameStrings.cantGoThere = readStringAt(*stream, IDI_HR1_OFS_STR_CANT_GO_THERE); _gameStrings.dontHaveIt = readStringAt(*stream, IDI_HR1_OFS_STR_DONT_HAVE_IT); _gameStrings.dontUnderstand = readStringAt(*stream, IDI_HR1_OFS_STR_DONT_UNDERSTAND); _gameStrings.gettingDark = readStringAt(*stream, IDI_HR1_OFS_STR_GETTING_DARK); // Load other strings from executable _strings.enterCommand = readStringAt(*stream, IDI_HR1_OFS_STR_ENTER_COMMAND); _strings.verbError = readStringAt(*stream, IDI_HR1_OFS_STR_VERB_ERROR); _strings.nounError = readStringAt(*stream, IDI_HR1_OFS_STR_NOUN_ERROR); _strings.playAgain = readStringAt(*stream, IDI_HR1_OFS_STR_PLAY_AGAIN); _strings.pressReturn = readStringAt(*stream, IDI_HR1_OFS_STR_PRESS_RETURN); _strings.lineFeeds = readStringAt(*stream, IDI_HR1_OFS_STR_LINE_FEEDS); // Set message IDs _messageIds.cantGoThere = IDI_HR1_MSG_CANT_GO_THERE; _messageIds.dontUnderstand = IDI_HR1_MSG_DONT_UNDERSTAND; _messageIds.itemDoesntMove = IDI_HR1_MSG_ITEM_DOESNT_MOVE; _messageIds.itemNotHere = IDI_HR1_MSG_ITEM_NOT_HERE; _messageIds.thanksForPlaying = IDI_HR1_MSG_THANKS_FOR_PLAYING; // Load message offsets stream->seek(IDI_HR1_OFS_MSGS); for (uint i = 0; i < IDI_HR1_NUM_MESSAGES; ++i) _messages.push_back(_files->getDataBlock(IDS_HR1_MESSAGES, stream->readUint16LE())); // Load picture data from executable stream->seek(IDI_HR1_OFS_PICS); for (uint i = 1; i <= IDI_HR1_NUM_PICS; ++i) { byte block = stream->readByte(); Common::String name = Common::String::format("BLOCK%i", block); uint16 offset = stream->readUint16LE(); _pictures[i] = _files->getDataBlock(name, offset); } // Load commands from executable stream->seek(IDI_HR1_OFS_CMDS_1); readCommands(*stream, _roomCommands); stream->seek(IDI_HR1_OFS_CMDS_0); readCommands(*stream, _globalCommands); // Load dropped item offsets stream->seek(IDI_HR1_OFS_ITEM_OFFSETS); loadDroppedItemOffsets(*stream, IDI_HR1_NUM_ITEM_OFFSETS); // Load right-angle line art stream->seek(IDI_HR1_OFS_CORNERS); uint16 cornersCount = stream->readUint16LE(); for (uint i = 0; i < cornersCount; ++i) _corners.push_back(_files->getDataBlock(IDS_HR1_EXE_1, IDI_HR1_OFS_CORNERS + stream->readUint16LE())); if (stream->eos() || stream->err()) error("Failed to read game data from '" IDS_HR1_EXE_1 "'"); stream->seek(IDI_HR1_OFS_VERBS); loadWords(*stream, _verbs, _priVerbs); stream->seek(IDI_HR1_OFS_NOUNS); loadWords(*stream, _nouns, _priNouns); }