Assets/Watson/Scripts/Services/RetrieveAndRank/RetrieveAndRank.cs
/// <summary>
/// Sends data to create and train a ranker and returns information about the new ranker. When the operation is successful, the status of the ranker is set to Training. The status must be Available before you can use the ranker.
/// </summary>
/// <param name="callback"></param>
/// <param name="trainingDataPath">Training data in CSV format. The first header must be question_id and the last header must be the relevance label. The other headers are alphanumeric feature names. For details, see Using your own data (http://www.ibm.com/watson/developercloud/doc/retrieve-rank/data_format.shtml).</param>
/// <param name="name">Metadata in JSON format. The metadata identifies an optional name to identify the ranker.</param>
/// <param name="customData"></param>
/// <returns></returns>
Sends data to create and train a ranker and returns information about the new ranker. When the operation is successful, the status of the ranker is set to Training. The status must be Available before you can use the ranker.
Sends data to create and train a ranker and returns information about the new ranker . When the operation is successful the status of the ranker is set to Training . The status must be Available before you can use the ranker .
public bool CreateRanker(OnCreateRanker callback, string trainingDataPath, string name = default(string), string customData = default(string))
		{
			if (callback == null)
				throw new ArgumentNullException("callback");
			if (string.IsNullOrEmpty(name))
				throw new ArgumentNullException("A ranker name is required to create a ranker!");
			if (string.IsNullOrEmpty(trainingDataPath))
				throw new ArgumentNullException("Training data is required to create a ranker!");
			CreateRankerRequest req = new CreateRankerRequest();
			req.Callback = callback;
			req.Name = name;
			req.TrainingDataPath = trainingDataPath;
			req.Data = customData;
            req.Timeout = REQUEST_TIMEOUT;
            byte[] trainingData;
			if (LoadFile != null)
			{
				trainingData = File.ReadAllBytes(trainingDataPath);
			}
			else
			{
#if !UNITY_WEBPLAYER
				trainingData = File.ReadAllBytes(trainingDataPath);
#endif
			}
			if (trainingData == null)
				Log.Error("RetrieveAndRank", "Failed to upload {0}!", trainingDataPath);
			RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, SERVICE_RANKERS);
			if (connector == null)
				return false;
			req.Forms = new Dictionary<string, RESTConnector.Form>();
			req.Forms["training_data"] = new RESTConnector.Form(trainingData, "training_data.csv", "text/csv");
			if (!string.IsNullOrEmpty(name))
			{
				string reqJson = "{\n\t\"name\": \"" + name + "\"\n}";
				req.Forms["training_metadata"] = new RESTConnector.Form(reqJson);
			}
			req.OnResponse = OnCreateRankerResponse;
			return connector.Send(req);
		}
public bool CreateRanker ( OnCreateRanker callback , string trainingDataPath , string name = default ( string ) , string customData = default ( string ) ) { if ( callback == null ) throw new ArgumentNullException ( " " ) ; if ( string . IsNullOrEmpty ( name ) ) throw new ArgumentNullException ( " " ) ; if ( string . IsNullOrEmpty ( trainingDataPath ) ) throw new ArgumentNullException ( " " ) ; CreateRankerRequest req = new CreateRankerRequest ( ) ; req . Callback = callback ; req . Name = name ; req . TrainingDataPath = trainingDataPath ; req . Data = customData ; req . Timeout = REQUEST_TIMEOUT ; byte [ ] trainingData ; if ( LoadFile != null ) { trainingData = File . ReadAllBytes ( trainingDataPath ) ; } else { if ! UNITY_WEBPLAYER trainingData = File . ReadAllBytes ( trainingDataPath ) ; endif } if ( trainingData == null ) Log . Error ( " " , " " , trainingDataPath ) ; RESTConnector connector = RESTConnector . GetConnector ( SERVICE_ID , SERVICE_RANKERS ) ; if ( connector == null ) return false ; req . Forms = new Dictionary < string , RESTConnector . Form > ( ) ; req . Forms [ " " ] = new RESTConnector . Form ( trainingData , " " , " " ) ; if ( ! string . IsNullOrEmpty ( name ) ) { string reqJson = " \n \t \" \" \" " + name + " \" \n " ; req . Forms [ " " ] = new RESTConnector . Form ( reqJson ) ; } req . OnResponse = OnCreateRankerResponse ; return connector . Send ( req ) ; }
Sends data to create and train a ranker and returns information about the new ranker.
Sends data to create and train a ranker and returns information about the new ranker .
None
callback
OnCreateRanker
None
trainingDataPath
string
Training data in CSV format. The first header must be question_id and the last header must be the relevance label. The other headers are alphanumeric feature names. For details, see Using your own data .
Training data in CSV format . The first header must be question_id and the last header must be the relevance label . The other headers are alphanumeric feature names . For details see Using your own data .
name
string
Metadata in JSON format. The metadata identifies an optional name to identify the ranker.
Metadata in JSON format . The metadata identifies an optional name to identify the ranker .
customData
string
None