/// <summary>
 /// Creates an entity that has a sentiment associated with it
 /// </summary>
 /// <param name="mention">The mention of the entity</param>
 /// <param name="normalizedMention">The normalized mention of the entity</param>
 /// <param name="id">The contextual ID of the entity to compare it against other entities</param>
 /// <param name="entityType">The entity type</param>
 /// <param name="count">The number of times the entity appeared in the text</param>
 /// <param name="sentiment">The contextual sentiment of the entity</param>
 /// <param name="confidence">The confidence that the sentiment was correctly identified</param>
 public RosetteSentimentEntity(String mention, String normalizedMention, EntityID id, String entityType, Nullable <int> count, String sentiment, Nullable <decimal> confidence) : base(mention, normalizedMention, id, entityType, count)
 {
     this.Sentiment = new SentimentResponse.RosetteSentiment(sentiment, confidence);
 }
Esempio n. 2
0
 public void SentimentTestFull()
 {
     Init();
     SentimentResponse.RosetteSentiment docSentiment = new SentimentResponse.RosetteSentiment("pos", (decimal)0.7962072011038756);
     RosetteSentimentEntity e0 = new RosetteSentimentEntity("Dan Akroyd", "Dan Akroyd", new EntityID("Q105221"), "PERSON", 2, "neg", (decimal)0.5005508052749595);
     RosetteSentimentEntity e1 = new RosetteSentimentEntity("The Hollywood Reporter", "The Hollywood Reporter", new EntityID("Q61503"), "ORGANIZATION", 1, "pos", (decimal)0.5338094035254866);
     List<RosetteSentimentEntity> entities = new List<RosetteSentimentEntity>() { e0, e1 };
     string headersAsString = " { \"Content-Type\": \"application/json\", \"date\": \"Thu, 11 Aug 2016 15:47:32 GMT\", \"server\": \"openresty\", \"strict-transport-security\": \"max-age=63072000; includeSubdomains; preload\", \"x-rosetteapi-app-id\": \"1409611723442\", \"x-rosetteapi-concurrency\": \"50\", \"x-rosetteapi-request-id\": \"d4176692-4f14-42d7-8c26-4b2d8f7ff049\", \"content-length\": \"72\", \"connection\": \"Close\" }";
     Dictionary<string, string> responseHeaders = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(headersAsString);
     Dictionary<string, object> content = new Dictionary<string, object>();
     content.Add("document", docSentiment);
     content.Add("entities", entities);
     SentimentResponse expected = new SentimentResponse(docSentiment, entities, responseHeaders, content, null);
     String mockedContent = expected.ContentToString();
     HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, mockedContent);
     _mockHttp.When(_testUrl + "sentiment").Respond(mockedMessage);
     SentimentResponse response = _rosetteApi.Sentiment("Original Ghostbuster Dan Aykroyd, who also co-wrote the 1984 Ghostbusters film, couldn’t be more pleased with the new all-female Ghostbusters cast, telling The Hollywood Reporter, “The Aykroyd family is delighted by this inheritance of the Ghostbusters torch by these most magnificent women in comedy.”");
     Assert.AreEqual(expected, response);
 }