Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jkho committed Jun 16, 2020
2 parents fc9b48c + 3610b76 commit daf23ef
Show file tree
Hide file tree
Showing 29 changed files with 3,508 additions and 457 deletions.
13 changes: 13 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright (c) 2014-2019 Basis Technology Corporation.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
49 changes: 25 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
[![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
## Rosette API
The Rosette Text Analytics Platform uses natural language processing, statistical modeling, and machine learning to
analyze unstructured and semi-structured text across 364 language-encoding-script combinations, revealing valuable
information and actionable data. Rosette provides endpoints for extracting entities and relationships, translating and
comparing the similarity of names, categorizing and adding linguistic tags to text and more.

## Installation
## Rosette API Access
- Rosette Cloud [Sign Up](https://developer.rosette.com/signup)
- Rosette Enterprise [Evaluation](https://www.rosette.com/product-eval/)

## Quick Start

#### Installation
If you use Nuget, you may use either Visual Studio's Nuget package manager or command line to install the Rosette API binding.

In Visual Studio: search for the [rosette_api package](https://www.nuget.org/packages/rosette_api/) in Nuget and follow the installation instructions.

Using Nuget Command Line: `nuget install rosette_api`.

If the version you are using is not [the latest from nuget](https://www.nuget.org/packages/rosette_api/),
please check for its [**compatibilty with api.rosette.com**](https://developer.rosette.com/features-and-functions?csharp).
If you have an on-premise version of Rosette API server, please contact support for
binding compatibility with your installation.

To check your installed version:

`nuget list rosette_api`

## Docker
A Docker image for running the examples against the compiled source library is available on Docker Hub.

Command: `docker run -e API_KEY=api-key -v "path-to-local-csharp-dir:/source" rosetteapi/docker-csharp`
#### Examples
View small example programs for each Rosette endpoint
in the [examples](https://github.com/rosette-api/csharp/tree/develop/rosette_apiExamples) directory.

Additional environment settings:
`-e ALT_URL=<alternative URL>`
`-e FILENAME=<single filename>`

## Basic Usage

See [examples](rosette_apiExamples)
#### Documentation & Support
- [Binding API](https://rosette-api.github.io/csharp/)
- [Rosette Platform API](https://developer.rosette.com/features-and-functions)
- [Binding Release Notes](https://github.com/rosette-api/csharp/wiki/Release-Notes)
- [Rosette Platform Release Notes](https://support.rosette.com/hc/en-us/articles/360018354971-Release-Notes)
- [Binding/Rosette Platform Compatibility](https://developer.rosette.com/features-and-functions?csharp#)
- [Support](https://support.rosette.com)
- [Binding License: Apache 2.0](https://github.com/rosette-api/csharp/blob/develop/LICENSE.txt)

## Concurrency
The C# binding uses HttpClient to manage connectivity and concurrency. By default, .NET sets the default connection limit to 2, which is the same as the Rosette API default limit. For Rosette API plans that allow for higher concurrency, the internal HTTP client will adjust automatically to the higher number. If a user chooses to provide their own HTTP client, no adjustment will be made. In this case it is up to the user to set `ServicePointManager.DefaultConnectionLimit` to the Rosette API concurrency level prior to instantiating the CAPI object.
Expand Down Expand Up @@ -111,11 +115,8 @@ For multithreaded operations, do not instantiate a new CAPI object for each thre
}
```

## API Documentation
See [documentation](http://rosette-api.github.io/csharp)

## Release Notes
Visit the [wiki](https://github.com/rosette-api/csharp/wiki/Release-Notes)

## Additional Information
Visit [Rosette API site](https://developer.rosette.com)

## Binding Developer Information
If you are modifying the binding code, please refer to the [developer README](https://github.com/rosette-api/csharp/tree/develop/DEVELOPER.md) file.
160 changes: 160 additions & 0 deletions rosette_api/Address.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
namespace rosette_api
{
public class Address: IAddress
{
public Address(string house = null, string houseNumber = null, string road = null, string unit = null, string level = null, string staircase = null, string entrance = null, string suburb = null, string cityDistrict = null, string city = null, string island = null, string stateDistrict = null, string state = null, string countryRegion = null, string country = null, string worldRegion = null, string postCode = null, string poBox = null)
{
this.house = house;
this.houseNumber = houseNumber;
this.road = road;
this.unit = unit;
this.level = level;
this.staircase = staircase;
this.entrance = entrance;
this.suburb = suburb;
this.cityDistrict = cityDistrict;
this.city = city;
this.island = island;
this.stateDistrict = stateDistrict;
this.state = state;
this.countryRegion = countryRegion;
this.country = country;
this.worldRegion = worldRegion;
this.postCode = postCode;
this.poBox = poBox;
}

/// <summary>house
/// <para>
/// Getter, Setter for the house
/// </para>
/// </summary>
public string house { get; set; }

/// <summary>houseNumber
/// <para>
/// Getter, Setter for the houseNumber
/// </para>
/// </summary>
public string houseNumber { get; set; }

/// <summary>road
/// <para>
/// Getter, Setter for the road
/// </para>
/// </summary>
public string road { get; set; }

/// <summary>unit
/// <para>
/// Getter, Setter for the unit
/// </para>
/// </summary>
public string unit { get; set; }

/// <summary>level
/// <para>
/// Getter, Setter for the level
/// </para>
/// </summary>
public string level { get; set; }

/// <summary>staircase
/// <para>
/// Getter, Setter for the staircase
/// </para>
/// </summary>
public string staircase { get; set; }

/// <summary>entrance
/// <para>
/// Getter, Setter for the entrance
/// </para>
/// </summary>
public string entrance { get; set; }

/// <summary>suburb
/// <para>
/// Getter, Setter for the suburb
/// </para>
/// </summary>
public string suburb { get; set; }

/// <summary>cityDistrict
/// <para>
/// Getter, Setter for the cityDistrict
/// </para>
/// </summary>
public string cityDistrict { get; set; }

/// <summary>city
/// <para>
/// Getter, Setter for the city
/// </para>
/// </summary>
public string city { get; set; }

/// <summary>island
/// <para>
/// Getter, Setter for the island
/// </para>
/// </summary>
public string island { get; set; }

/// <summary>stateDistrict
/// <para>
/// Getter, Setter for the stateDistrict
/// </para>
/// </summary>
public string stateDistrict { get; set; }

/// <summary>state
/// <para>
/// Getter, Setter for the state
/// </para>
/// </summary>
public string state { get; set; }

/// <summary>countryRegion
/// <para>
/// Getter, Setter for the countryRegion
/// </para>
/// </summary>
public string countryRegion { get; set; }

/// <summary>country
/// <para>
/// Getter, Setter for the country
/// </para>
/// </summary>
public string country { get; set; }

/// <summary>worldRegion
/// <para>
/// Getter, Setter for the worldRegion
/// </para>
/// </summary>
public string worldRegion { get; set; }

/// <summary>postCode
/// <para>
/// Getter, Setter for the postCode
/// </para>
/// </summary>
public string postCode { get; set; }

/// <summary>poBox
/// <para>
/// Getter, Setter for the poBox
/// </para>
/// </summary>
public string poBox { get; set; }

/// <summary> is this address fielded?
/// </summary>
public bool fielded()
{
return true;
}
}
}
73 changes: 73 additions & 0 deletions rosette_api/AddressSimilarityResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using System.Net.Http;

namespace rosette_api
{
/// <summary>
/// A class to represnt the results from the Name Similarity endpoint of the Rosette API
/// </summary>
[JsonObject(MemberSerialization.OptOut)]
public class AddressSimilarityResponse : RosetteResponse
{
private const string scoreKey = "score";

/// <summary>
/// The score, on a range of 0-1, of how closely the names match
/// </summary>
[JsonProperty(scoreKey)]
public Nullable<double> Score;

/// <summary>
/// Creates a AddressSimilarityResponse from the given apiResults
/// </summary>
/// <param name="apiResults">The message from the API</param>
public AddressSimilarityResponse(HttpResponseMessage apiResults) :base(apiResults)
{
if (this.ContentDictionary.ContainsKey(scoreKey))
{
this.Score = this.ContentDictionary[scoreKey] as double?;
}
}

/// <summary>
/// Creates a AddressSimilarityResponse from its headers
/// </summary>
/// <param name="score">The name simiarity score: 0-1</param>
/// <param name="responseHeaders">The response headers from the API</param>
/// <param name="content">The content of the response (the score) in dictionary form</param>
/// <param name="contentAsJSON">The content in JSON</param>
public AddressSimilarityResponse(double? score, Dictionary<string, string> responseHeaders, Dictionary<string, object> content, string contentAsJSON) : base(responseHeaders, content, contentAsJSON)
{
this.Score = score;
}

/// <summary>
/// Equals override.
/// </summary>
/// <param name="obj">The object to compare against</param>
/// <returns>True if equal.</returns>
public override bool Equals(object obj)
{
if (obj is AddressSimilarityResponse)
{
AddressSimilarityResponse other = obj as AddressSimilarityResponse;
return this.Score == other.Score && this.ResponseHeaders.Equals(other.ResponseHeaders);
}
else
{
return false;
}
}

/// <summary>
/// HashCode override
/// </summary>
/// <returns>The hashcode</returns>
public override int GetHashCode()
{
return this.Score.GetHashCode() ^ this.ResponseHeaders.GetHashCode();
}
}
}
36 changes: 36 additions & 0 deletions rosette_api/CAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,42 @@ public void ClearUrlParameters() {
_urlParameters.Clear();
}

/// <summary>AddressSimilarity
/// <para>
/// (POST)AddressSimilarity Endpoint: Returns the result of matching 2 addresses.
/// </para>
/// </summary>
/// <param name="a1">IAddress: First address to be matched</param>
/// <param name="a2">IAddress: Second address to be matched</param>
/// <returns>AddressSimilarityResponse containing the results of the request.
/// </returns>
public AddressSimilarityResponse AddressSimilarity(IAddress a1, IAddress a2)
{
_uri = "address-similarity";

Dictionary<object, object> dict = new Dictionary<object, object>(){
{ "address1", a1},
{ "address2", a2}
};

return GetResponse<AddressSimilarityResponse>(JsonConvert.SerializeObject(AppendOptions(dict)));
}

/// <summary>AddressSimilarity
/// <para>
/// (POST)AddressSimilarity Endpoint: Returns the result of matching 2 addresses.
/// </para>
/// </summary>
/// <param name="dict">Dictionary&lt;object, object&gt;: Dictionary containing parameters as (key,value) pairs</param>
/// <returns>AddressSimilarityResponse containing the results of the request.
/// </returns>
public AddressSimilarityResponse AddressSimilarity(Dictionary<object, object> dict) {
_uri = "address-similarity";
return GetResponse<AddressSimilarityResponse>(JsonConvert.SerializeObject(AppendOptions(dict)));
}



/// <summary>Categories
/// <para>
/// (POST)Categories Endpoint: Returns an ordered list of categories identified in the input. The categories are Tier 1 contextual categories defined in the QAG Taxonomy.
Expand Down
Loading

0 comments on commit daf23ef

Please sign in to comment.