Assets/Watson/Scripts/Services/RetrieveAndRank/RetrieveAndRank.cs
/// <summary>
/// Returns the top answer and a list of ranked answers with their ranked scores and confidence values. Use the Get information about a ranker method to retrieve the status (http://www.ibm.com/watson/developercloud/retrieve-and-rank/api/v1/#get_status). Use this method to return answers when you train the ranker with custom features. However, in most cases, you can use the Search and rank method (http://www.ibm.com/watson/developercloud/retrieve-and-rank/api/v1/#query_ranker).
/// </summary>
/// <param name="callback"></param>
/// <param name="rankerID">ID of the ranker to use.</param>
/// <param name="searchResultPath">The path to the CSV file that contains the search results that you want to rank. The first column header of the CSV must be labeled answer_id. The remaining column headers must match the names of the features in the training data that was used when this ranker was created.</param>
/// <param name="customData"></param>
/// <returns></returns>
Returns the top answer and a list of ranked answers with their ranked scores and confidence values. Use the Get information about a ranker method to retrieve the status . Use this method to return answers when you train the ranker with custom features. However, in most cases, you can use the Search and rank method .
Returns the top answer and a list of ranked answers with their ranked scores and confidence values . Use the Get information about a ranker method to retrieve the status . Use this method to return answers when you train the ranker with custom features . However in most cases you can use the Search and rank method .
public bool Rank(OnRank callback, string rankerID, string searchResultPath = default(string), string customData = default(string))
		{
			if (callback == null)
				throw new ArgumentNullException("callback");
			if (string.IsNullOrEmpty(rankerID))
				throw new ArgumentNullException("A rankerID is required rank!");
			if (string.IsNullOrEmpty(searchResultPath))
				throw new ArgumentNullException("Search results are required to rank!");
			RankRequest req = new RankRequest();
			req.Callback = callback;
			req.RankerID = rankerID;
			req.SearchResultsPath = searchResultPath;
			req.Data = customData;
            req.Timeout = REQUEST_TIMEOUT;
            byte[] searchResultData;
			if (LoadFile != null)
			{
				searchResultData = File.ReadAllBytes(searchResultPath);
			}
			else
			{
#if !UNITY_WEBPLAYER
				searchResultData = File.ReadAllBytes(searchResultPath);
#endif
			}
			if (searchResultData == null)
				Log.Error("RetrieveAndRank", "Failed to upload {0}!", searchResultData);
			RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, string.Format(SERVICE_RANK, rankerID));
			if (connector == null)
				return false;
			req.Forms = new Dictionary<string, RESTConnector.Form>();
			req.Forms["answer_data"] = new RESTConnector.Form(searchResultData, "searck_data.csv", "text/csv");
			req.OnResponse = OnRankResponse;
			return connector.Send(req);
		}
public bool Rank ( OnRank callback , string rankerID , string searchResultPath = default ( string ) , string customData = default ( string ) ) { if ( callback == null ) throw new ArgumentNullException ( " " ) ; if ( string . IsNullOrEmpty ( rankerID ) ) throw new ArgumentNullException ( " " ) ; if ( string . IsNullOrEmpty ( searchResultPath ) ) throw new ArgumentNullException ( " " ) ; RankRequest req = new RankRequest ( ) ; req . Callback = callback ; req . RankerID = rankerID ; req . SearchResultsPath = searchResultPath ; req . Data = customData ; req . Timeout = REQUEST_TIMEOUT ; byte [ ] searchResultData ; if ( LoadFile != null ) { searchResultData = File . ReadAllBytes ( searchResultPath ) ; } else { if ! UNITY_WEBPLAYER searchResultData = File . ReadAllBytes ( searchResultPath ) ; endif } if ( searchResultData == null ) Log . Error ( " " , " " , searchResultData ) ; RESTConnector connector = RESTConnector . GetConnector ( SERVICE_ID , string . Format ( SERVICE_RANK , rankerID ) ) ; if ( connector == null ) return false ; req . Forms = new Dictionary < string , RESTConnector . Form > ( ) ; req . Forms [ " " ] = new RESTConnector . Form ( searchResultData , " " , " " ) ; req . OnResponse = OnRankResponse ; return connector . Send ( req ) ; }
Returns the top answer and a list of ranked answers with their ranked scores and confidence values.
Returns the top answer and a list of ranked answers with their ranked scores and confidence values .
//req.Headers["Content-Type"] = "multipart/form-data"; //req.Headers["Accept"] = "*/*";
None
callback
OnRank
None
rankerID
string
ID of the ranker to use.
ID of the ranker to use .
searchResultPath
string
The path to the CSV file that contains the search results that you want to rank. The first column header of the CSV must be labeled answer_id. The remaining column headers must match the names of the features in the training data that was used when this ranker was created.
The path to the CSV file that contains the search results that you want to rank . The first column header of the CSV must be labeled answer_id . The remaining column headers must match the names of the features in the training data that was used when this ranker was created .
customData
string
None