public ActionResult Sentiment(string text) { var sr = new SentimentRequest(); sr.Documents.Add(new Document() { Text = text, Id = "Sample Text" }); var result = SentimentService.GetSentiment(sr); return(View("Sentiment", result)); }
public Task <float> Get(string message, [FromServices] ISentimentService sentimentService) { var cacheKey = GetHash(message); var value = _cache.Get(cacheKey); if (value != null) { var data = Encoding.UTF8.GetString(value); if (!string.IsNullOrEmpty(data)) { return(Task.FromResult(float.Parse(data))); } } return(sentimentService.GetSentiment(message)); }