Skip to content

Commit daf23ef

Browse files
committed
Merge branch 'develop'
2 parents fc9b48c + 3610b76 commit daf23ef

29 files changed

+3508
-457
lines changed

LICENSE.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright (c) 2014-2019 Basis Technology Corporation.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

README.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,40 @@
11
[![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)
22

3-
## .Net (C#) client binding for the Rosette API
3+
## Rosette API
4+
The Rosette Text Analytics Platform uses natural language processing, statistical modeling, and machine learning to
5+
analyze unstructured and semi-structured text across 364 language-encoding-script combinations, revealing valuable
6+
information and actionable data. Rosette provides endpoints for extracting entities and relationships, translating and
7+
comparing the similarity of names, categorizing and adding linguistic tags to text and more.
48

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

13+
## Quick Start
14+
15+
#### Installation
716
If you use Nuget, you may use either Visual Studio's Nuget package manager or command line to install the Rosette API binding.
817

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

1120
Using Nuget Command Line: `nuget install rosette_api`.
1221

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

2024
`nuget list rosette_api`
2125

22-
## Docker
23-
A Docker image for running the examples against the compiled source library is available on Docker Hub.
24-
25-
Command: `docker run -e API_KEY=api-key -v "path-to-local-csharp-dir:/source" rosetteapi/docker-csharp`
26+
#### Examples
27+
View small example programs for each Rosette endpoint
28+
in the [examples](https://github.com/rosette-api/csharp/tree/develop/rosette_apiExamples) directory.
2629

27-
Additional environment settings:
28-
`-e ALT_URL=<alternative URL>`
29-
`-e FILENAME=<single filename>`
30-
31-
## Basic Usage
32-
33-
See [examples](rosette_apiExamples)
30+
#### Documentation & Support
31+
- [Binding API](https://rosette-api.github.io/csharp/)
32+
- [Rosette Platform API](https://developer.rosette.com/features-and-functions)
33+
- [Binding Release Notes](https://github.com/rosette-api/csharp/wiki/Release-Notes)
34+
- [Rosette Platform Release Notes](https://support.rosette.com/hc/en-us/articles/360018354971-Release-Notes)
35+
- [Binding/Rosette Platform Compatibility](https://developer.rosette.com/features-and-functions?csharp#)
36+
- [Support](https://support.rosette.com)
37+
- [Binding License: Apache 2.0](https://github.com/rosette-api/csharp/blob/develop/LICENSE.txt)
3438

3539
## Concurrency
3640
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.
@@ -111,11 +115,8 @@ For multithreaded operations, do not instantiate a new CAPI object for each thre
111115
}
112116
```
113117

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

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

120-
## Additional Information
121-
Visit [Rosette API site](https://developer.rosette.com)
120+
121+
## Binding Developer Information
122+
If you are modifying the binding code, please refer to the [developer README](https://github.com/rosette-api/csharp/tree/develop/DEVELOPER.md) file.

rosette_api/Address.cs

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
namespace rosette_api
2+
{
3+
public class Address: IAddress
4+
{
5+
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)
6+
{
7+
this.house = house;
8+
this.houseNumber = houseNumber;
9+
this.road = road;
10+
this.unit = unit;
11+
this.level = level;
12+
this.staircase = staircase;
13+
this.entrance = entrance;
14+
this.suburb = suburb;
15+
this.cityDistrict = cityDistrict;
16+
this.city = city;
17+
this.island = island;
18+
this.stateDistrict = stateDistrict;
19+
this.state = state;
20+
this.countryRegion = countryRegion;
21+
this.country = country;
22+
this.worldRegion = worldRegion;
23+
this.postCode = postCode;
24+
this.poBox = poBox;
25+
}
26+
27+
/// <summary>house
28+
/// <para>
29+
/// Getter, Setter for the house
30+
/// </para>
31+
/// </summary>
32+
public string house { get; set; }
33+
34+
/// <summary>houseNumber
35+
/// <para>
36+
/// Getter, Setter for the houseNumber
37+
/// </para>
38+
/// </summary>
39+
public string houseNumber { get; set; }
40+
41+
/// <summary>road
42+
/// <para>
43+
/// Getter, Setter for the road
44+
/// </para>
45+
/// </summary>
46+
public string road { get; set; }
47+
48+
/// <summary>unit
49+
/// <para>
50+
/// Getter, Setter for the unit
51+
/// </para>
52+
/// </summary>
53+
public string unit { get; set; }
54+
55+
/// <summary>level
56+
/// <para>
57+
/// Getter, Setter for the level
58+
/// </para>
59+
/// </summary>
60+
public string level { get; set; }
61+
62+
/// <summary>staircase
63+
/// <para>
64+
/// Getter, Setter for the staircase
65+
/// </para>
66+
/// </summary>
67+
public string staircase { get; set; }
68+
69+
/// <summary>entrance
70+
/// <para>
71+
/// Getter, Setter for the entrance
72+
/// </para>
73+
/// </summary>
74+
public string entrance { get; set; }
75+
76+
/// <summary>suburb
77+
/// <para>
78+
/// Getter, Setter for the suburb
79+
/// </para>
80+
/// </summary>
81+
public string suburb { get; set; }
82+
83+
/// <summary>cityDistrict
84+
/// <para>
85+
/// Getter, Setter for the cityDistrict
86+
/// </para>
87+
/// </summary>
88+
public string cityDistrict { get; set; }
89+
90+
/// <summary>city
91+
/// <para>
92+
/// Getter, Setter for the city
93+
/// </para>
94+
/// </summary>
95+
public string city { get; set; }
96+
97+
/// <summary>island
98+
/// <para>
99+
/// Getter, Setter for the island
100+
/// </para>
101+
/// </summary>
102+
public string island { get; set; }
103+
104+
/// <summary>stateDistrict
105+
/// <para>
106+
/// Getter, Setter for the stateDistrict
107+
/// </para>
108+
/// </summary>
109+
public string stateDistrict { get; set; }
110+
111+
/// <summary>state
112+
/// <para>
113+
/// Getter, Setter for the state
114+
/// </para>
115+
/// </summary>
116+
public string state { get; set; }
117+
118+
/// <summary>countryRegion
119+
/// <para>
120+
/// Getter, Setter for the countryRegion
121+
/// </para>
122+
/// </summary>
123+
public string countryRegion { get; set; }
124+
125+
/// <summary>country
126+
/// <para>
127+
/// Getter, Setter for the country
128+
/// </para>
129+
/// </summary>
130+
public string country { get; set; }
131+
132+
/// <summary>worldRegion
133+
/// <para>
134+
/// Getter, Setter for the worldRegion
135+
/// </para>
136+
/// </summary>
137+
public string worldRegion { get; set; }
138+
139+
/// <summary>postCode
140+
/// <para>
141+
/// Getter, Setter for the postCode
142+
/// </para>
143+
/// </summary>
144+
public string postCode { get; set; }
145+
146+
/// <summary>poBox
147+
/// <para>
148+
/// Getter, Setter for the poBox
149+
/// </para>
150+
/// </summary>
151+
public string poBox { get; set; }
152+
153+
/// <summary> is this address fielded?
154+
/// </summary>
155+
public bool fielded()
156+
{
157+
return true;
158+
}
159+
}
160+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Newtonsoft.Json;
4+
using System.Net.Http;
5+
6+
namespace rosette_api
7+
{
8+
/// <summary>
9+
/// A class to represnt the results from the Name Similarity endpoint of the Rosette API
10+
/// </summary>
11+
[JsonObject(MemberSerialization.OptOut)]
12+
public class AddressSimilarityResponse : RosetteResponse
13+
{
14+
private const string scoreKey = "score";
15+
16+
/// <summary>
17+
/// The score, on a range of 0-1, of how closely the names match
18+
/// </summary>
19+
[JsonProperty(scoreKey)]
20+
public Nullable<double> Score;
21+
22+
/// <summary>
23+
/// Creates a AddressSimilarityResponse from the given apiResults
24+
/// </summary>
25+
/// <param name="apiResults">The message from the API</param>
26+
public AddressSimilarityResponse(HttpResponseMessage apiResults) :base(apiResults)
27+
{
28+
if (this.ContentDictionary.ContainsKey(scoreKey))
29+
{
30+
this.Score = this.ContentDictionary[scoreKey] as double?;
31+
}
32+
}
33+
34+
/// <summary>
35+
/// Creates a AddressSimilarityResponse from its headers
36+
/// </summary>
37+
/// <param name="score">The name simiarity score: 0-1</param>
38+
/// <param name="responseHeaders">The response headers from the API</param>
39+
/// <param name="content">The content of the response (the score) in dictionary form</param>
40+
/// <param name="contentAsJSON">The content in JSON</param>
41+
public AddressSimilarityResponse(double? score, Dictionary<string, string> responseHeaders, Dictionary<string, object> content, string contentAsJSON) : base(responseHeaders, content, contentAsJSON)
42+
{
43+
this.Score = score;
44+
}
45+
46+
/// <summary>
47+
/// Equals override.
48+
/// </summary>
49+
/// <param name="obj">The object to compare against</param>
50+
/// <returns>True if equal.</returns>
51+
public override bool Equals(object obj)
52+
{
53+
if (obj is AddressSimilarityResponse)
54+
{
55+
AddressSimilarityResponse other = obj as AddressSimilarityResponse;
56+
return this.Score == other.Score && this.ResponseHeaders.Equals(other.ResponseHeaders);
57+
}
58+
else
59+
{
60+
return false;
61+
}
62+
}
63+
64+
/// <summary>
65+
/// HashCode override
66+
/// </summary>
67+
/// <returns>The hashcode</returns>
68+
public override int GetHashCode()
69+
{
70+
return this.Score.GetHashCode() ^ this.ResponseHeaders.GetHashCode();
71+
}
72+
}
73+
}

rosette_api/CAPI.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,42 @@ public void ClearUrlParameters() {
347347
_urlParameters.Clear();
348348
}
349349

350+
/// <summary>AddressSimilarity
351+
/// <para>
352+
/// (POST)AddressSimilarity Endpoint: Returns the result of matching 2 addresses.
353+
/// </para>
354+
/// </summary>
355+
/// <param name="a1">IAddress: First address to be matched</param>
356+
/// <param name="a2">IAddress: Second address to be matched</param>
357+
/// <returns>AddressSimilarityResponse containing the results of the request.
358+
/// </returns>
359+
public AddressSimilarityResponse AddressSimilarity(IAddress a1, IAddress a2)
360+
{
361+
_uri = "address-similarity";
362+
363+
Dictionary<object, object> dict = new Dictionary<object, object>(){
364+
{ "address1", a1},
365+
{ "address2", a2}
366+
};
367+
368+
return GetResponse<AddressSimilarityResponse>(JsonConvert.SerializeObject(AppendOptions(dict)));
369+
}
370+
371+
/// <summary>AddressSimilarity
372+
/// <para>
373+
/// (POST)AddressSimilarity Endpoint: Returns the result of matching 2 addresses.
374+
/// </para>
375+
/// </summary>
376+
/// <param name="dict">Dictionary&lt;object, object&gt;: Dictionary containing parameters as (key,value) pairs</param>
377+
/// <returns>AddressSimilarityResponse containing the results of the request.
378+
/// </returns>
379+
public AddressSimilarityResponse AddressSimilarity(Dictionary<object, object> dict) {
380+
_uri = "address-similarity";
381+
return GetResponse<AddressSimilarityResponse>(JsonConvert.SerializeObject(AppendOptions(dict)));
382+
}
383+
384+
385+
350386
/// <summary>Categories
351387
/// <para>
352388
/// (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.

0 commit comments

Comments
 (0)