Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Park committed Dec 19, 2016
2 parents d330c88 + dde485e commit c52c70f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 148 deletions.
65 changes: 6 additions & 59 deletions rosette_api/CAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,56 +277,6 @@ public CategoriesResponse Categories(RosetteFile file) {
return Process<CategoriesResponse>(file);
}

/// deprecated
/// <summary>EntitiesLinked
/// <para>
/// (POST)EntitiesLinked Endpoint: Links entities in the input to entities in the knowledge base.
/// </para>
/// </summary>
/// <param name="content">(string, optional): Input to process (JSON string or base64 encoding of non-JSON string)</param>
/// <param name="language">(string, optional): Language: ISO 639-3 code (ignored for the /language endpoint)</param>
/// <param name="contentType">(string, optional): not used at this time</param>
/// <param name="contentUri">(string, optional): URI to accessible content (content and contentUri are mutually exclusive)</param>
/// <param name="genre">(string, optional): genre to categorize the input data</param>
/// <returns>EntitiesResponse containing the results of the request.
/// </returns>
[Obsolete("Use Entity endpoint.")]
public EntitiesResponse EntitiesLinked(string content = null, string language = null, string contentType = null, string contentUri = null, string genre = null)
{
return Entity(content, language, contentType, contentUri, true, genre);
}

/// deprecated
/// <summary>EntitiesLinked
/// <para>
/// (POST)EntitiesLinked Endpoint: Links entities in the input to entities in the knowledge base.
/// </para>
/// </summary>
/// <param name="dict">Dictionary&lt;object, object&gt;: Dictionary containing parameters as (key,value) pairs</param>
/// <returns>EntitiesResponse containing the results of the request.
/// </returns>
[Obsolete("Use Entity endpoint.")]
public EntitiesResponse EntitiesLinked(Dictionary<object, object> dict)
{
return Entity(dict, true);
}

/// deprecated
/// <summary>EntitiesLinked
/// <para>
/// (POST)EntitiesLinked Endpoint: Links entities in the input to entities in the knowledge base.
/// </para>
/// </summary>
/// <param name="file">RosetteFile: RosetteFile Object containing the file (and possibly options) to upload</param>
/// <returns>EntitiesResponse containing the results of the request.
/// </returns>
[Obsolete("Use Entity endpoint.")]
public EntitiesResponse EntitiesLinked(RosetteFile file)
{
return Entity(file, true);
}


/// <summary>Entity
/// <para>
/// (POST)Entity Endpoint: Returns each entity extracted from the input.
Expand All @@ -336,13 +286,12 @@ public EntitiesResponse EntitiesLinked(RosetteFile file)
/// <param name="language">(string, optional): Language: ISO 639-3 code (ignored for the /language endpoint)</param>
/// <param name="contentType">(string, optional): not used at this time</param>
/// <param name="contentUri">(string, optional): URI to accessible content (content and contentUri are mutually exclusive)</param>
/// <param name="resolveEntities">(string, optional): use /entities/linked as opposed to /entities</param>
/// <param name="genre">(string, optional): genre to categorize the input data</param>
/// <returns>EntitiesResponse containing the results of the request.
/// </returns>
public EntitiesResponse Entity(string content = null, string language = null, string contentType = null, string contentUri = null, bool resolveEntities = false, string genre = null)
public EntitiesResponse Entity(string content = null, string language = null, string contentType = null, string contentUri = null, string genre = null)
{
_uri = resolveEntities ? "entities/linked" : "entities";
_uri = "entities";
return Process<EntitiesResponse>(content, language, contentType, contentUri, genre);
}

Expand All @@ -352,12 +301,11 @@ public EntitiesResponse Entity(string content = null, string language = null, st
/// </para>
/// </summary>
/// <param name="dict">Dictionary&lt;object, object&gt;: Dictionary containing parameters as (key,value) pairs</param>
/// <param name="resolveEntities">(string, optional): use /entities/linked as opposed to /entities</param>
/// <returns>EntitiesResponse containing the results of the request.
/// </returns>
public EntitiesResponse Entity(Dictionary<object, object> dict, bool resolveEntities = false)
public EntitiesResponse Entity(Dictionary<object, object> dict)
{
_uri = resolveEntities ? "entities/linked" : "entities";
_uri = "entities";
return getResponse<EntitiesResponse>(SetupClient(), new JavaScriptSerializer().Serialize(appendOptions(dict)));
}

Expand All @@ -367,11 +315,10 @@ public EntitiesResponse Entity(Dictionary<object, object> dict, bool resolveEnti
/// </para>
/// </summary>
/// <param name="file">RosetteFile: RosetteFile Object containing the file (and possibly options) to upload</param>
/// <param name="resolveEntities">(string, optional): use /entities/linked as opposed to /entities</param>
/// <returns>EntitiesResponse containing the results of the request.
/// </returns>
public EntitiesResponse Entity(RosetteFile file, bool resolveEntities = false) {
_uri = resolveEntities ? "entities/linked" : "entities";
public EntitiesResponse Entity(RosetteFile file) {
_uri = "entities";
return Process<EntitiesResponse>(file);
}

Expand Down
6 changes: 3 additions & 3 deletions rosette_api/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.4.1.0")]
[assembly: AssemblyVersion("1.4.1.0")]
[assembly: AssemblyFileVersion("1.4.1.0")]
// [assembly: AssemblyVersion("1.5.0.0")]
[assembly: AssemblyVersion("1.5.0.0")]
[assembly: AssemblyFileVersion("1.5.0.0")]
2 changes: 1 addition & 1 deletion rosette_api/rosette_api.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>rosette_api</id>
<version>1.4.1</version>
<version>1.5.0</version>
<authors>basistech</authors>
<owners>basistech</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
Expand Down
1 change: 0 additions & 1 deletion rosette_apiExamples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Each example, when run, prints its output to the console.
| ------------- |------------- |
| categories.cs | Gets the category of a document at a URL |
| entities.cs | Gets the entities from a piece of text |
| entities_linked.cs | Gets the linked (to Wikipedia) entities from a piece of text |
| info.cs | Gets information about Rosette API |
| language.cs | Gets the language of a piece of text |
| matched-name.cs | Gets the similarity score of two names |
Expand Down
2 changes: 1 addition & 1 deletion rosette_apiExamples/entities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static void Main(string[] args)
CAPI EntitiesCAPI = string.IsNullOrEmpty(alturl) ? new CAPI(apikey) : new CAPI(apikey, alturl);
string entities_text_data = @"Bill Murray will appear in new Ghostbusters film: Dr. Peter Venkman was spotted filming a cameo in Boston this… http://dlvr.it/BnsFfS";
//The results of the API call will come back in the form of a Dictionary
EntitiesResponse response = EntitiesCAPI.Entity(entities_text_data, null, null, null, false, "social-media");
EntitiesResponse response = EntitiesCAPI.Entity(entities_text_data, null, null, null, "social-media");
foreach (KeyValuePair<string, string> h in response.Headers) {
Console.WriteLine(string.Format("{0}:{1}", h.Key, h.Value));
}
Expand Down
48 changes: 0 additions & 48 deletions rosette_apiExamples/entities_linked.cs

This file was deleted.

50 changes: 15 additions & 35 deletions rosette_apiUnitTests/rosette_apiUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ public void doTest() {
}
}

/// <summary>
/// Live test for Relationships. To run, uncomment [Test]
/// </summary>
[TestFixture]
public class liveRelationshipTest {
//[Test]
public void doTest() {

CAPI rosetteApi = new CAPI("boguskey", "http://jugmaster.basistech.net:8181/rest/v1", 1);
RelationshipsResponse result = rosetteApi.Relationships(@"Bill Gates, Microsoft's former CEO, is a philanthropist.");
System.Diagnostics.Debug.WriteLine(result.ToString());

}
}

[TestFixture]
public class rosetteResponseTests {
private string _testHeaderKey;
Expand Down Expand Up @@ -599,41 +614,6 @@ public void Categories_File_Test() {
# pragma warning restore 618
}

//------------------------- Entities Linked ----------------------------------------

[Test]
public void EntitiesLinked_Content_Test() {
_mockHttp.When(_testUrl + "entities/linked")
.Respond(HttpStatusCode.OK, "application/json", "{'response': 'OK'}");

var response = _rosetteApi.Entity("content", null, null, null, true);
# pragma warning disable 618
Assert.AreEqual(response.Content["response"], "OK");
# pragma warning restore 618
}

[Test]
public void EntitiesLinked_Dict_Test() {
_mockHttp.When(_testUrl + "entities/linked")
.Respond(HttpStatusCode.OK, "application/json", "{'response': 'OK'}");

var response = _rosetteApi.Entity(new Dictionary<object, object>() { { "contentUri", "contentUrl" } }, true);
# pragma warning disable 618
Assert.AreEqual(response.Content["response"], "OK");
# pragma warning restore 618
}

[Test]
public void EntitiesLinked_File_Test() {
_mockHttp.When(_testUrl + "entities/linked")
.Respond("application/json", "{'response': 'OK'}");

RosetteFile f = new RosetteFile(_tmpFile);
var response = _rosetteApi.Entity(f, true);
# pragma warning disable 618
Assert.AreEqual(response.Content["response"], "OK");
# pragma warning restore 618
}

//------------------------- Entity ----------------------------------------
[Test]
Expand Down

0 comments on commit c52c70f

Please sign in to comment.