diff --git a/README.md b/README.md index 582ecb44..2b956359 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/rosette-api/csharp.svg?branch=master)](https://travis-ci.org/rosette-api/csharp) +[![Build Status](https://travis-ci.org/rosette-api/csharp.svg?branch=master)](https://travis-ci.org/rosette-api/csharp) [![NuGet version](https://badge.fury.io/nu/rosette_api.svg)](https://badge.fury.io/nu/rosette_api) ## .Net (C#) client binding for the Rosette API diff --git a/rosette_api/EntitiesResponse.cs b/rosette_api/EntitiesResponse.cs index 641ec8b3..4724e728 100644 --- a/rosette_api/EntitiesResponse.cs +++ b/rosette_api/EntitiesResponse.cs @@ -31,9 +31,11 @@ public class EntitiesResponse : RosetteResponse private const String countKey = "count"; private const String confidenceKey = "confidence"; private const String dbpediaTypeKey = "dbpediaType"; + private const String dbpediaTypesKey = "dbpediaTypes"; private const String mentionOffsetsKey = "mentionOffsets"; private const String linkingConfidenceKey = "linkingConfidence"; private const String salienceKey = "salience"; + private const String permIdKey = "permId"; /// /// Creates an EntitiesResponse from the API's raw output @@ -53,11 +55,13 @@ public EntitiesResponse(HttpResponseMessage apiResult) : base(apiResult) Nullable count = result.Properties().Where((p) => String.Equals(p.Name, countKey)).Any() ? result[countKey].ToObject() : null; Nullable confidence = result.Properties().Where((p) => String.Equals(p.Name, confidenceKey)).Any() ? result[confidenceKey].ToObject() : null; String dbpediaType = result.Properties().Where((p) => String.Equals(p.Name, dbpediaTypeKey, StringComparison.OrdinalIgnoreCase)).Any() ? result[dbpediaTypeKey].ToString() : null; - JArray mentionOffsetsArr = result.Properties().Where((p) => String.Equals(p.Name, dbpediaTypeKey, StringComparison.OrdinalIgnoreCase)).Any() ? result[mentionOffsetsKey] as JArray : null; + List dbpediaTypes = result.Properties().Where((p) => String.Equals(p.Name, dbpediaTypesKey, StringComparison.OrdinalIgnoreCase)).Any() ? result[dbpediaTypesKey].ToObject>() : null; + JArray mentionOffsetsArr = result.Properties().Where((p) => String.Equals(p.Name, mentionOffsetsKey, StringComparison.OrdinalIgnoreCase)).Any() ? result[mentionOffsetsKey] as JArray : null; List mentionOffsets = mentionOffsetsArr != null ? mentionOffsetsArr.ToObject>() : null; Nullable linkingConfidence = result.Properties().Where((p) => String.Equals(p.Name, linkingConfidenceKey, StringComparison.OrdinalIgnoreCase)).Any() ? result[linkingConfidenceKey].ToObject() : null; Nullable salience = result.Properties().Where((p) => String.Equals(p.Name, salienceKey, StringComparison.OrdinalIgnoreCase)).Any() ? result[salienceKey].ToObject() : null; - entities.Add(new RosetteEntity(mention, normalized, entityID, type, count, confidence, dbpediaType, mentionOffsets, linkingConfidence, salience)); + String permId = result.Properties().Where((p) => String.Equals(p.Name, permIdKey, StringComparison.OrdinalIgnoreCase)).Any() ? result[permIdKey].ToString() : null; + entities.Add(new RosetteEntity(mention, normalized, entityID, type, count, confidence, dbpediaType, dbpediaTypes, mentionOffsets, linkingConfidence, salience, permId)); } this.Entities = entities; } diff --git a/rosette_api/Properties/AssemblyInfo.cs b/rosette_api/Properties/AssemblyInfo.cs index 50f60ba5..066439ec 100644 --- a/rosette_api/Properties/AssemblyInfo.cs +++ b/rosette_api/Properties/AssemblyInfo.cs @@ -31,6 +31,6 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -// [assembly: AssemblyVersion("1.12.2.0")] -[assembly: AssemblyVersion("1.12.2.0")] -[assembly: AssemblyFileVersion("1.12.2.0")] +// [assembly: AssemblyVersion("1.14.0.0")] +[assembly: AssemblyVersion("1.14.0.0")] +[assembly: AssemblyFileVersion("1.14.0.0")] diff --git a/rosette_api/RosetteEntity.cs b/rosette_api/RosetteEntity.cs index 58ea4ff4..b1f5701a 100644 --- a/rosette_api/RosetteEntity.cs +++ b/rosette_api/RosetteEntity.cs @@ -123,9 +123,16 @@ public class RosetteEntity : IEquatable /// /// Gets or sets the dbpediaType of the extracted entity /// + [Obsolete("Use dbPediaTypes instead.")] [JsonProperty("dbpediaType", NullValueHandling = NullValueHandling.Ignore)] public String DBpediaType { get; set; } + /// + /// Gets or sets the dbpediaTypes of the extracted entity + /// + [JsonProperty("dbpediaTypes", NullValueHandling = NullValueHandling.Ignore)] + public List DBpediaTypes { get; set; } + /// /// Gets or sets the offsets of the extracted entity /// @@ -144,6 +151,12 @@ public class RosetteEntity : IEquatable [JsonProperty("salience", NullValueHandling = NullValueHandling.Ignore)] public Nullable Salience { get; set; } + /// + /// Gets or sets the permId of the extracted entity + /// + [JsonProperty("permId", NullValueHandling = NullValueHandling.Ignore)] + public String PermID { get; set; } + /// /// Creates an entity /// @@ -154,12 +167,14 @@ public class RosetteEntity : IEquatable /// The number of times this entity appeared in the input to the API /// The confidence of this entity appeared in the input to the API /// The DBpedia type of the entity + /// A list of DBpedia types of the entitiy /// The mention offsets of the entity /// The linking confidence of the entity /// The salience of the entity + /// The Thomson Reuters Permanent Identifier of the entity public RosetteEntity(string mention, string normalizedMention, EntityID id, string entityType, int? count, - double? confidence, string dbpediaType, List mentionOffsets, double? linkingConfidence, - double? salience) + double? confidence, string dbpediaType, List dbpediaTypes, List mentionOffsets, + double? linkingConfidence, double? salience, string permId) { this.Mention = mention; this.NormalizedMention = normalizedMention; @@ -168,9 +183,25 @@ public RosetteEntity(string mention, string normalizedMention, EntityID id, stri this.EntityType = entityType; this.Confidence = confidence; this.DBpediaType = dbpediaType; + this.DBpediaTypes = dbpediaTypes; this.MentionOffsets = mentionOffsets; this.LinkingConfidence = linkingConfidence; this.Salience = salience; + this.PermID = permId; + } + + /// + /// Method to compare Lists of Strings. SequenceEqual throws an exception + /// if either argument is null. + /// + /// List + /// List + /// True if equal or both null + private bool StringListsAreEqual(List list1, List list2) + { + if(list1 == null && list2 == null) { return true; } + if(list1 == null || list2 == null) { return false; } // only one is null + return list1.SequenceEqual(list2); } /// @@ -187,9 +218,11 @@ public bool Equals(RosetteEntity other) && Count == other.Count && Confidence.Equals(other.Confidence) && string.Equals(DBpediaType, other.DBpediaType) + && StringListsAreEqual(DBpediaTypes, other.DBpediaTypes) && MentionOffsets.SequenceEqual(other.MentionOffsets) && LinkingConfidence.Equals(other.LinkingConfidence) - && Salience.Equals(other.Salience); + && Salience.Equals(other.Salience) + && string.Equals(PermID, other.PermID); } /// @@ -220,9 +253,11 @@ public override int GetHashCode() hashCode = (hashCode * 397) ^ Count.GetHashCode(); hashCode = (hashCode * 397) ^ Confidence.GetHashCode(); hashCode = (hashCode * 397) ^ (DBpediaType != null ? DBpediaType.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (DBpediaTypes != null ? DBpediaTypes.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (MentionOffsets != null ? MentionOffsets.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (LinkingConfidence != null ? LinkingConfidence.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Salience != null ? Salience.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (PermID != null ? PermID.GetHashCode() : 0); return hashCode; } } diff --git a/rosette_api/SentimentResponse.cs b/rosette_api/SentimentResponse.cs index 80ec9e73..d92402e7 100644 --- a/rosette_api/SentimentResponse.cs +++ b/rosette_api/SentimentResponse.cs @@ -24,6 +24,7 @@ public class SentimentResponse : RosetteResponse, IEquatable internal const string mentionKey = "mention"; internal const string normalizedMentionKey = "normalized"; internal const string dbpediaTypeKey = "dbpediaType"; + internal const string dbpediaTypesKey = "dbpediaTypes"; internal const string countKey = "count"; internal const string typeKey = "type"; internal const string entityIDKey = "entityId"; @@ -31,6 +32,7 @@ public class SentimentResponse : RosetteResponse, IEquatable internal const String mentionOffsetsKey = "mentionOffsets"; internal const String linkingConfidenceKey = "linkingConfidence"; internal const String salienceKey = "salience"; + internal const String permIdKey = "permId"; /// /// Gets or sets the document-level sentiment identified by the Rosette API @@ -64,17 +66,19 @@ public SentimentResponse(HttpResponseMessage apiResult) string entityIDStr = result.Properties().Where((p) => p.Name == entityIDKey).Any() ? result[entityIDKey].ToString() : null; EntityID entityID = entityIDStr != null ? new EntityID(entityIDStr) : null; string dbpediaType = result.Properties().Where((p) => p.Name == dbpediaTypeKey).Any() ? result[dbpediaTypeKey].ToString() : null; + List dbpediaTypes = result.Properties().Where((permIdKey) => permIdKey.Name == dbpediaTypesKey).Any() ? result[dbpediaTypesKey].ToObject>() : null; Nullable count = result.Properties().Where((p) => p.Name == countKey).Any() ? result[countKey].ToObject() : null; Nullable confidence = result.Properties().Where((p) => String.Equals(p.Name, confidenceKey)).Any() ? result[confidenceKey].ToObject() : null; JArray mentionOffsetsArr = result.Properties().Where((p) => p.Name == mentionOffsetsKey).Any() ? result[mentionOffsetsKey] as JArray : null; List mentionOffsets = mentionOffsetsArr != null ? mentionOffsetsArr.ToObject>() : null; Nullable linkingConfidence = result.Properties().Where((p) => p.Name == linkingConfidenceKey).Any() ? result[linkingConfidenceKey].ToObject() : null; Nullable salience = result.Properties().Where((p) => p.Name == salienceKey).Any() ? result[salienceKey].ToObject() : null; + String permId = result.Properties().Where((p) => p.Name == permIdKey).Any() ? result[permIdKey].ToString() : null; RosetteSentiment sentiment = null; if (result.Properties().Where((p) => p.Name == sentimentKey).Any()) { sentiment = result[sentimentKey].ToObject(); } - entitySentiments.Add(new RosetteSentimentEntity(mention, normalizedMention, entityID, type, count, sentiment, confidence, dbpediaType, mentionOffsets, linkingConfidence, salience)); + entitySentiments.Add(new RosetteSentimentEntity(mention, normalizedMention, entityID, type, count, sentiment, confidence, dbpediaType, dbpediaTypes, mentionOffsets, linkingConfidence, salience, permId)); } this.EntitySentiments = entitySentiments; } @@ -282,9 +286,11 @@ public class RosetteSentimentEntity : RosetteEntity, IEquatableThe contextual sentiment of the entity /// The confidence that the sentiment was correctly identified /// The DBpedia type of the entity + /// A list of DBpedia types of the entitiy /// The mention offsets of the entity /// The linking confidence of the entity /// The salience of the entity + /// The Thomson Reuters Permanent Identifier of the entity public RosetteSentimentEntity(string mention, string normalizedMention, EntityID id, @@ -293,9 +299,11 @@ public RosetteSentimentEntity(string mention, SentimentResponse.RosetteSentiment sentiment, double? confidence, string dbpediaType, + List dbpediaTypes, List mentionOffsets, double? linkingConfidence, - double? salience + double? salience, + String permId ) : base(mention, normalizedMention, id, @@ -303,9 +311,11 @@ public RosetteSentimentEntity(string mention, count, confidence, dbpediaType, + dbpediaTypes, mentionOffsets, linkingConfidence, - salience + salience, + permId ) { this.Sentiment = new SentimentResponse.RosetteSentiment(sentiment.Label, sentiment.Confidence); diff --git a/rosette_api/rosette_api.nuspec b/rosette_api/rosette_api.nuspec index a73353a2..be56e35c 100644 --- a/rosette_api/rosette_api.nuspec +++ b/rosette_api/rosette_api.nuspec @@ -2,10 +2,10 @@ rosette_api - 1.12.2 + 1.14.0 basistech basistech - http://www.apache.org/licenses/LICENSE-2.0 + Apache-2.0 false .Net (C#) Binding for Rosette API .Net (C#) Binding updated for Rosette API diff --git a/rosette_apiUnitTests/rosette_apiUnitTests.cs b/rosette_apiUnitTests/rosette_apiUnitTests.cs index b6eeb9ea..3895a2e1 100755 --- a/rosette_apiUnitTests/rosette_apiUnitTests.cs +++ b/rosette_apiUnitTests/rosette_apiUnitTests.cs @@ -472,7 +472,7 @@ public void InfoTestFull() string version = "1.2.3"; string buildNumber = null; string buildTime = null; - 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\" }"; + 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 content = new Dictionary { { "name", name }, { "version", version }, @@ -525,7 +525,7 @@ public void PingTestFull() { Init(); string message = "Rosette API at your service."; long time = 1470930452887; - 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\" }"; + 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 content = new Dictionary { { "message", message }, { "time", time } @@ -607,7 +607,7 @@ public void CategoriesContentTestFull() List categories = new List(); RosetteCategory cat0 = new RosetteCategory("ARTS_AND_ENTERTAINMENT", (decimal)0.23572849069656435, (decimal)0.12312312312312312); categories.Add(cat0); - 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\" }"; + 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 content = new Dictionary { { "categories", categories } }; @@ -649,11 +649,11 @@ public void Categories_File_Test() { public void EntityTestFull() { Init(); - RosetteEntity e0 = new RosetteEntity("Dan Akroyd", "Dan Akroyd", new EntityID("Q105221"), "PERSON", 2, 0.99, "X1", new List() { new MentionOffset(0, 10), new MentionOffset(20,32) }, .99, 1); - RosetteEntity e1 = new RosetteEntity("The Hollywood Reporter", "The Hollywood Reporter", new EntityID("Q61503"), "ORGANIZATION", 1, null, "X1", new List() { new MentionOffset(15, 18) }, null, null); - RosetteEntity e2 = new RosetteEntity("Dan Akroyd", "Dan Akroyd", new EntityID("Q105221"), "PERSON", 2, 0.99, "X1", new List() { new MentionOffset(0, 10), new MentionOffset(20, 32) }, .99, 0.0); + RosetteEntity e0 = new RosetteEntity("Dan Akroyd", "Dan Akroyd", new EntityID("Q105221"), "PERSON", 2, 0.99, "X1", null, new List() { new MentionOffset(0, 10), new MentionOffset(20,32) }, .99, 1, null); + RosetteEntity e1 = new RosetteEntity("The Hollywood Reporter", "The Hollywood Reporter", new EntityID("Q61503"), "ORGANIZATION", 1, null, "X1", null, new List() { new MentionOffset(15, 18) }, null, null, null); + RosetteEntity e2 = new RosetteEntity("Dan Akroyd", "Dan Akroyd", new EntityID("Q105221"), "PERSON", 2, 0.99, "X1", null, new List() { new MentionOffset(0, 10), new MentionOffset(20, 32) }, .99, 0.0, null); List entities = new List() { e0, e1, e2 }; - 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\" }"; + 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 responseHeaders = new JavaScriptSerializer().Deserialize>(headersAsString); Dictionary content = new Dictionary { { "entities", entities } @@ -666,6 +666,46 @@ public void EntityTestFull() Assert.AreEqual(expected, response); } + [Test] + public void EntityTestExtendedProperties() { + // Entities response, based on Cloud defaults, with linkEntities, + // includeDBpediaType, includeDBpediaTypes and includePermID set to true. + + Init(); + + String e_type = "ORGANIZATION"; + String e_mention = "Toyota"; + String e_normalized = "Toyota"; + Nullable e_count = 1; + Nullable e_confidence = null; + List e_mentionOffsets = new List() { new MentionOffset(0, 6) }; + EntityID e_entityID = new EntityID("Q53268"); + Nullable e_linkingConfidence = 0.14286868; + Nullable e_salience = null; + String e_dbpediaType = "Agent/Organisation"; + List e_dbpediaTypes = new List() {"Agent/Organisation"}; + String e_permId = "4295876746"; + + RosetteEntity e = new RosetteEntity(e_mention, e_normalized, e_entityID, e_type, e_count, e_confidence, + e_dbpediaType, e_dbpediaTypes, e_mentionOffsets, e_linkingConfidence, e_salience, e_permId); + List entities = new List() { e }; + Dictionary content = new Dictionary { { "entities", entities } }; + + 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 responseHeaders = new JavaScriptSerializer().Deserialize>(headersAsString); + + EntitiesResponse expected = new EntitiesResponse(entities, responseHeaders, content, null); + String mockedContent = expected.ContentToString(); + HttpResponseMessage mockedMessage = MakeMockedMessage(responseHeaders, HttpStatusCode.OK, mockedContent); + _mockHttp.When(_testUrl + "entities").Respond(req => mockedMessage); + EntitiesResponse response = _rosetteApi.Entity("Toyota"); + + Assert.AreEqual(expected, response); + Assert.AreEqual(expected.Entities[0].PermID, response.Entities[0].PermID); + Assert.AreEqual(expected.Entities[0].DBpediaType, response.Entities[0].DBpediaType); + Assert.AreEqual(expected.Entities[0].DBpediaTypes, response.Entities[0].DBpediaTypes); + } + [Test] public void Entity_Content_Test() { _mockHttp.When(_testUrl + "entities") @@ -740,7 +780,7 @@ public void LanguageTestFull() LanguageDetection lang7 = new LanguageDetection("fin", (decimal)0.23572849069656435); LanguageDetection lang8 = new LanguageDetection("fra", (decimal)0.023298946617300347); List languageDetections = new List() { lang0, lang1, lang2, lang3, lang4, lang5, lang6, lang7, lang8 }; - 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\" }"; + 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 responseHeaders = new JavaScriptSerializer().Deserialize>(headersAsString); Dictionary content = new Dictionary { { "languageDetections", languageDetections } @@ -799,7 +839,7 @@ public void MorphologyTestFullComplete() MorphologyItem m4 = new MorphologyItem("jumped", "VERB", "jump", new List(), new List()); MorphologyItem m5 = new MorphologyItem(".", "PUNCT", ".", new List(), new List()); List morphology = new List() { m0, m1, m2, m3, m4, m5 }; - 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\" }"; + 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 responseHeaders = new JavaScriptSerializer().Deserialize>(headersAsString); Dictionary content = new Dictionary { { "tokens", new List(morphology.Select((item) => item.Token)) }, @@ -827,7 +867,7 @@ public void MorphologyTestFullLemmas() MorphologyItem m4 = new MorphologyItem("jumped", null, "jump", null, null); MorphologyItem m5 = new MorphologyItem(".", null, ".", null, null); List morphology = new List() { m0, m1, m2, m3, m4, m5 }; - 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\" }"; + 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 responseHeaders = new JavaScriptSerializer().Deserialize>(headersAsString); Dictionary content = new Dictionary { { "tokens", new List(morphology.Select((item) => item.Token)) } @@ -850,7 +890,7 @@ public void MorphologyTestFullCompoundComponents() List compoundComponents = new List() { "Rechts", "Schutz", "Versicherungs", "Gesellschaft" }; MorphologyItem m1 = new MorphologyItem("Rechtsschutzversicherungsgesellschaft", null, null, compoundComponents, null); List morphology = new List() { m0, m1 }; - 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\" }"; + 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 responseHeaders = new JavaScriptSerializer().Deserialize>(headersAsString); Dictionary content = new Dictionary { { "tokens", new List(morphology.Select((item) => item.Token)) } @@ -876,7 +916,7 @@ public void MorphologyTestFullHanReadings() MorphologyItem m1 = new MorphologyItem("生物系", null, null, null, h1); MorphologyItem m2 = new MorphologyItem("主任", null, null, null, h2); List morphology = new List() { m0, m1, m2 }; - 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\" }"; + 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 responseHeaders = new JavaScriptSerializer().Deserialize>(headersAsString); Dictionary content = new Dictionary { { "tokens", new List(morphology.Select((item) => item.Token)) } @@ -931,7 +971,7 @@ public void NameSimilarityTestFull() { Init(); double score = (double)0.9486632809417912; - 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\" }"; + 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 responseHeaders = new JavaScriptSerializer().Deserialize>(headersAsString); Dictionary content = new Dictionary { { "score", score } @@ -1051,7 +1091,7 @@ public void RelationshipsTestFull() string loc1 = "in Boston"; List locatives = new List() {loc1}; HashSet modalities = new HashSet() {"assertion", "someOtherModality"}; - 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\" }"; + 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 responseHeaders = new JavaScriptSerializer().Deserialize>(headersAsString); List relationships = new List() { new RosetteRelationship(predicate, new Dictionary() {{1, arg1}}, new Dictionary() {{1, arg1ID}}, null, locatives, null, confidence, modalities) @@ -1077,7 +1117,7 @@ public void RelationshipsTestFullNoArgID() string loc1 = "in Boston"; List locatives = new List() { loc1 }; HashSet modalities = new HashSet() { "assertion", "someOtherModality" }; - 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\" }"; + 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 responseHeaders = new JavaScriptSerializer().Deserialize>(headersAsString); List relationships = new List() { new RosetteRelationship(predicate, new Dictionary() {{1, arg1}}, new Dictionary(), null, locatives, null, confidence, modalities) @@ -1149,7 +1189,7 @@ public void SemanticVectorsTestFull() { Init(); List vector = new List() {0.02164695, 0.0032850206, 0.0038508752, -0.009704393, -0.0016203842}; - 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\" }"; + 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 responseHeaders = new JavaScriptSerializer().Deserialize>(headersAsString); Dictionary content = new Dictionary { { "documentEmbedding", vector }, @@ -1209,7 +1249,7 @@ public void SimilarTermsTestFull() IDictionary> terms = new Dictionary>() { {"eng", new List() {new SimilarTerm("spy", 1.0m)}} }; - 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\" }"; + 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 responseHeaders = new JavaScriptSerializer().Deserialize>(headersAsString); Dictionary content = new Dictionary() { {"similarTerms", terms} @@ -1269,7 +1309,7 @@ public void SentencesTestFull() string s1 = "This land is my land\nFrom California to the New York island;\nFrom the red wood forest to the Gulf Stream waters\n\nThis land was made for you and Me.\n\n"; string s2 = "As I was walking that ribbon of highway,\nI saw above me that endless skyway:\nI saw below me that golden valley:\nThis land was made for you and me."; List sentences = new List() { s0, s1, s2 }; - 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\" }"; + 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 responseHeaders = new JavaScriptSerializer().Deserialize>(headersAsString); Dictionary content = new Dictionary { { "sentences", sentences } @@ -1322,10 +1362,10 @@ public void SentimentTestFull() { Init(); SentimentResponse.RosetteSentiment docSentiment = new SentimentResponse.RosetteSentiment("pos", (double)0.7962072011038756); - RosetteSentimentEntity e0 = new RosetteSentimentEntity("Dan Akroyd", "Dan Akroyd", new EntityID("Q105221"), "PERSON", 2, docSentiment, (double)0.5005508052749595, null, new List() { new MentionOffset(0, 10), new MentionOffset(20, 32) }, .99, 1); - RosetteSentimentEntity e1 = new RosetteSentimentEntity("The Hollywood Reporter", "The Hollywood Reporter", new EntityID("Q61503"), "ORGANIZATION", 1, docSentiment, (double)0.5338094035254866, null, new List() { new MentionOffset(15, 18) }, null, null); + RosetteSentimentEntity e0 = new RosetteSentimentEntity("Dan Akroyd", "Dan Akroyd", new EntityID("Q105221"), "PERSON", 2, docSentiment, (double)0.5005508052749595, null, null, new List() { new MentionOffset(0, 10), new MentionOffset(20, 32) }, .99, 1, null); + RosetteSentimentEntity e1 = new RosetteSentimentEntity("The Hollywood Reporter", "The Hollywood Reporter", new EntityID("Q61503"), "ORGANIZATION", 1, docSentiment, (double)0.5338094035254866, null, null, new List() { new MentionOffset(15, 18) }, null, null, null); List entities = new List() { 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\" }"; + 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 responseHeaders = new JavaScriptSerializer().Deserialize>(headersAsString); Dictionary content = new Dictionary { { "document", docSentiment }, @@ -1386,7 +1426,7 @@ public void SyntaxDependenciesTestFull() SyntaxDependenciesResponse.SentenceWithDependencies sentence = new SyntaxDependenciesResponse.SentenceWithDependencies(0, 4, dependencies); List sentences = new List() { sentence }; List tokens = new List() { "Sony", "Pictures", "is", "planning", "."}; - 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\" }"; + 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 responseHeaders = new JavaScriptSerializer().Deserialize>(headersAsString); Dictionary content = new Dictionary { { "sentences", sentences }, @@ -1450,7 +1490,7 @@ public void TokensTestFull() "内部", "会议" }; - 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\" }"; + 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 responseHeaders = new JavaScriptSerializer().Deserialize>(headersAsString); Dictionary content = new Dictionary { { "tokens", tokens } @@ -1507,7 +1547,7 @@ public void NameTranslationTestFull() string targetScript = "Latn"; string targetScheme = "IC"; double confidence = (double)0.06856099342585828; - 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\" }"; + 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 responseHeaders = new JavaScriptSerializer().Deserialize>(headersAsString); Dictionary content = new Dictionary { { "translation", translation }, @@ -1573,7 +1613,7 @@ public void TopicsTestFull() { new KeyPhrase("Scorpius Malfoy", null), new KeyPhrase("Nicholas Hoult", null) }; - 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\" }"; + 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 responseHeaders = new JavaScriptSerializer().Deserialize>(headersAsString); Dictionary content = new Dictionary { { "concepts", concepts },