Exemplo n.º 1
0
Scorer* setup_metric(po::variables_map& cfg, std::string& metric, bool& normalize) {

	metric = UppercaseString(cfg["weight_metric"].as<string>());
	Scorer*s = NULL;
	if (metric == "TFIDF")
		s = new TFIDF();
	else if (metric == "BM25") {
		s = new BM25();
		s->setAvgDocLength(cfg["avg_len"].as<double>());
	} else if (metric == "STFIDF")
		s = new STFIDF();

	if (cfg.count("normalize"))
		normalize = true;

	return s;
}
Exemplo n.º 2
0
string UppercaseString(const string& ioString)
{
    string theReturnString = ioString;
    UppercaseString(theReturnString);
    return theReturnString;
}
Exemplo n.º 3
0
void AvHGamerules::InitializeAuthentication()
{
	bool theSuccess = false;

	ALERT(at_console, "\tReading authentication data...");

    struct MemoryStruct theChunk;
	CURLcode theCode = PopulateChunkFromURL(BuildAuthenticationURL(), theChunk);
	
	// Now parse data and add users for each mask
	if((theCode == CURLE_OK) && theChunk.memory)
	{
        // Clear existing authentication data, only after lookup succeeds
        gAuthMaskList.clear();

		string theString(theChunk.memory);
		string theDelimiters("\r\n");
		StringVector theLines;
		Tokenizer::split(theString, theDelimiters, theLines);
		
		// Run through each line
		int theNumConstellationMembers = 0;
		for(StringVector::const_iterator theIter = theLines.begin(); theIter != theLines.end(); theIter++)
		{
			char *msg=(char *)(*theIter).c_str();
			// If it's not empty and not a comment
			char theFirstChar = (*theIter)[0];
			if((theFirstChar != '/') && (theFirstChar != '#'))
			{
				// Split up tag and number
				StringVector theTokens;
				if(Tokenizer::split(*theIter, " ", theTokens) == 3)
				{
					// Translate tag to auth mask
					string theTag = theTokens[0];
					string theWONID = theTokens[1];
					string theSteamID = theTokens[2];

                    // Upper-case prefix
                    UppercaseString(theSteamID);

                    // Make sure it starts with "STEAM_X:Y"
					if(strncmp(theSteamID.c_str(), kSteamIDPrefix, strlen(kSteamIDPrefix)))
                    {
                        string theNewSteamID = kSteamIDPrefix + theSteamID;
                        theSteamID = theNewSteamID;
                    }

					// Add auth status
					AvHPlayerAuthentication theMask = PLAYERAUTH_NONE;
					if(TagToAuthMask(theTag, theMask))
					{
						// Count Constellation members fyi
						if(theMask & PLAYERAUTH_CONTRIBUTOR)
						{
							theNumConstellationMembers++;
						}

						if((theWONID != "") || (theSteamID != ""))
						{
#ifdef DEBUG
							char theMessage[512];
							sprintf(theMessage, "	Adding auth mask: %s %s %s\n", theTag.c_str(), theWONID.c_str(), theSteamID.c_str());
							ALERT(at_logged, theMessage);
#endif
							
							this->AddAuthStatus(theMask, theWONID, theSteamID);
							theSuccess = true;
						}
					}
				}
			}
		}

		// Breakpoint to see how many Constellation members there are (don't even think of printing or logging)
		int a = 0;
	}
    else
    {
        int a = 0;
    }

	// Now build server op list
	this->mServerOpList.clear();
		
	// Parse contents server op variable
	string theServerOpsString(avh_serverops.string);
	
	// Tokenize string
	StringVector theServerOpsStrings;
	Tokenizer::split(theServerOpsString, ";", theServerOpsStrings);
	
	// For each in list, add as an int to our list
	for(StringVector::const_iterator theIter = theServerOpsStrings.begin(); theIter != theServerOpsStrings.end(); theIter++)
	{
		// Add whatever the put in this line as both the WONID and SteamID
		string theCurrentAuthID = *theIter;
		this->mServerOpList.push_back( make_pair(theCurrentAuthID, theCurrentAuthID));
	}
	
	if(theSuccess)
	{
		ALERT(at_console, "success.\n");
	}
	else
	{
		ALERT(at_console, "failure.\n");
	}
	gTimeLastUpdatedUplink = AvHSUTimeGetTime();
}