public async Task <HistogramResult> CalcHistogramAsync(string expression, AcademicModelOptions model, string attributes = "", int count = 10, int offset = 0) { StringBuilder sb = new StringBuilder(); if (!string.IsNullOrEmpty(attributes)) { sb.Append($"&attributes={attributes}"); } if (count > 0) { sb.Append($"&count={count}"); } if (offset > 0) { sb.Append($"&offset={offset}"); } var modelName = Enum.GetName(typeof(AcademicModelOptions), model).Replace("beta2015", "beta-2015"); var response = await SendGetAsync($"{calcUrl}?expr={expression}&model={modelName}{sb}"); return(JsonConvert.DeserializeObject <HistogramResult>(response)); }
public async Task <EvaluateResponse> EvaluateAsync(string expression, AcademicModelOptions model, int count = 10, int offset = 0, string attributes = "", string orderby = "") { StringBuilder sb = new StringBuilder(); if (count > 0) { sb.Append($"&count={count}"); } if (offset > 0) { sb.Append($"&offset={offset}"); } if (!string.IsNullOrEmpty(orderby)) { sb.Append($"&orderby={orderby}"); } if (!string.IsNullOrEmpty(attributes)) { sb.Append($"&attributes={attributes}"); } var modelName = Enum.GetName(typeof(AcademicModelOptions), model).Replace("beta2015", "beta-2015"); var response = await this.SendGetAsync($"{evaluateUrl}?expr={expression}&model={modelName}{sb}"); return(JsonConvert.DeserializeObject <EvaluateResponse>(response)); }
/// <summary> /// /// </summary> /// <param name="expression">Example: Composite(AA.AuN='sue dumais') - See: https://www.microsoft.com/cognitive-services/en-us/Academic-Knowledge-API/documentation/QueryExpressionSyntax</param> /// <param name="model"></param> /// <param name="attributes"></param> /// <param name="count"></param> /// <param name="offset"></param> /// <returns></returns> public virtual EvaluateResponse Evaluate(string expression, AcademicModelOptions model, int count = 10, int offset = 0, string attributes = "", string orderby = "") { var qs = GetEvaluateQuerystring(count, offset, orderby, attributes); var modelName = GetModelName(model); var response = RepositoryClient.SendGet(ApiKeys.Academic, $"{ApiKeys.AcademicEndpoint}{evaluateUrl}?expr={expression}&model={modelName}{qs}"); return(JsonConvert.DeserializeObject <EvaluateResponse>(response)); }
/// <summary> /// /// </summary> /// <param name="expression">Example: Composite(AA.AuN='sue dumais') - See: https://www.microsoft.com/cognitive-services/en-us/Academic-Knowledge-API/documentation/QueryExpressionSyntax</param> /// <param name="model"></param> /// <param name="attributes"></param> /// <param name="count"></param> /// <param name="offset"></param> /// <returns></returns> public virtual CalcHistogramResponse CalcHistogram(string expression, AcademicModelOptions model, string attributes = "", int count = 10, int offset = 0) { var qs = GetCalcQuerystring(attributes, count, offset); var modelName = GetModelName(model); var response = RepositoryClient.SendGet(ApiKeys.Academic, $"{ApiKeys.AcademicEndpoint}{calcUrl}?expr={expression}&model={modelName}{qs}"); return(JsonConvert.DeserializeObject <CalcHistogramResponse>(response)); }
public virtual EvaluateResponse Evaluate(string expression, AcademicModelOptions model, int count = 10, int offset = 0, string attributes = "", string orderby = "") { return(PolicyService.ExecuteRetryAndCapture400Errors( "AcademicSearchService.Evaluate", ApiKeys.AcademicRetryInSeconds, () => { var result = AcademicSearchRepository.Evaluate(expression, model, count, offset, attributes, orderby); return result; }, null)); }
public virtual CalcHistogramResponse CalcHistogram(string expression, AcademicModelOptions model, string attributes = "", int count = 10, int offset = 0) { return(PolicyService.ExecuteRetryAndCapture400Errors( "AcademicSearchService.CalcHistogram", ApiKeys.AcademicRetryInSeconds, () => { var result = AcademicSearchRepository.CalcHistogram(expression, model, attributes, count, offset); return result; }, null)); }
public virtual EvaluateResponse Evaluate(string expression, AcademicModelOptions model, int count = 10, int offset = 0, string attributes = "", string orderby = "") { try { var result = Task.Run(async() => await AcademicSearchRepository.EvaluateAsync(expression, model, count, offset, attributes, orderby)).Result; return(result); } catch (Exception ex) { Logger.Error("AcademicSearchService.Evaluate failed", this, ex); } return(null); }
public virtual HistogramResult CalcHistogram(string expression, AcademicModelOptions model, string attributes = "", int count = 10, int offset = 0) { try { var result = Task.Run(async() => await AcademicSearchRepository.CalcHistogramAsync(expression, model, attributes, count, offset)).Result; return(result); } catch (Exception ex) { Logger.Error("AcademicSearchService.CalcHistogram failed", this, ex); } return(null); }
public virtual InterpretResponse Interpret(string query, bool complete = false, int count = 10, int offset = 0, int timeout = 0, AcademicModelOptions model = AcademicModelOptions.latest) { return(PolicyService.ExecuteRetryAndCapture400Errors( "AcademicSearchService.Interpret", ApiKeys.AcademicRetryInSeconds, () => { var result = AcademicSearchRepository.Interpret(query, complete, count, offset, timeout, model); return result; }, null)); }
/// <summary> /// /// </summary> /// <param name="expression">Example: Composite(AA.AuN='sue dumais') - See: https://www.microsoft.com/cognitive-services/en-us/Academic-Knowledge-API/documentation/QueryExpressionSyntax</param> /// <param name="model"></param> /// <param name="attributes"></param> /// <param name="count"></param> /// <param name="offset"></param> /// <returns></returns> public EvaluateResponse Evaluate(string expression, AcademicModelOptions model, int count = 10, int offset = 0, string attributes = "", string orderby = "") { return(Task.Run(async() => await EvaluateAsync(expression, model, count, offset, attributes, orderby)).Result); }
/// <summary> /// /// </summary> /// <param name="expression">Example: Composite(AA.AuN='sue dumais') - See: https://www.microsoft.com/cognitive-services/en-us/Academic-Knowledge-API/documentation/QueryExpressionSyntax</param> /// <param name="model"></param> /// <param name="attributes"></param> /// <param name="count"></param> /// <param name="offset"></param> /// <returns></returns> public HistogramResult CalcHistogram(string expression, AcademicModelOptions model, string attributes = "", int count = 10, int offset = 0) { return(Task.Run(async() => await CalcHistogramAsync(expression, model, attributes, count, offset)).Result); }
public async Task <InterpretResponse> InterpretAsync(string query, bool complete = false, int count = 10, int offset = 0, int timeout = 0, AcademicModelOptions model = AcademicModelOptions.latest) { StringBuilder sb = new StringBuilder(); if (complete) { sb.Append($"complete={complete}"); } if (count > 0) { sb.Append($"&count={count}"); } if (offset > 0) { sb.Append($"&offset={offset}"); } if (timeout > 0) { sb.Append($"&timeout={timeout}"); } var modelName = Enum.GetName(typeof(AcademicModelOptions), model).Replace("beta2015", "beta-2015"); var response = await SendGetAsync($"{interpretUrl}?query={query}&model={modelName}{sb}"); return(JsonConvert.DeserializeObject <InterpretResponse>(response)); }
/// <param name="query">Query entered by user. If complete is set to 1, query will be interpreted as a prefix for generating query auto-completion suggestions.</param> /// <param name="complete">1 means that auto-completion suggestions are generated based on the grammar and graph data.</param> /// <param name="count">Maximum number of interpretations to return.</param> /// <param name="offset">Index of the first interpretation to return. For example, count=2&offset=0 returns interpretations 0 and 1. count=2&offset=2 returns interpretations 2 and 3.</param> /// <param name="timeout">Timeout in milliseconds.Only interpretations found before the timeout has elapsed are returned.</param> /// <param name="model">Name of the model that you wish to query.Currently, the value defaults to "latest".</param> /// <returns></returns> public InterpretResponse Interpret(string query, bool complete = false, int count = 10, int offset = 0, int timeout = 0, AcademicModelOptions model = AcademicModelOptions.latest) { return(Task.Run(async() => await InterpretAsync(query, complete, count, offset, timeout, model)).Result); }
protected virtual string GetModelName(AcademicModelOptions model) { return(Enum.GetName(typeof(AcademicModelOptions), model).Replace("beta2015", "beta-2015")); }
public virtual async Task <InterpretResponse> InterpretAsync(string query, bool complete = false, int count = 10, int offset = 0, int timeout = 0, AcademicModelOptions model = AcademicModelOptions.latest) { var qs = GetInterpretQuerystring(complete, count, offset, timeout); var modelName = GetModelName(model); var response = await RepositoryClient.SendGetAsync(ApiKeys.Academic, $"{ApiKeys.AcademicEndpoint}{interpretUrl}?query={query}&model={modelName}{qs}"); return(JsonConvert.DeserializeObject <InterpretResponse>(response)); }
public virtual InterpretResponse Interpret(string query, bool complete = false, int count = 10, int offset = 0, int timeout = 0, AcademicModelOptions model = AcademicModelOptions.latest) { try { var result = Task.Run(async() => await AcademicSearchRepository.InterpretAsync(query, complete, count, offset, timeout, model)).Result; return(result); } catch (Exception ex) { Logger.Error("AcademicSearchService.Interpret failed", this, ex); } return(null); }