Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions examples/AddressSimilarity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using Rosette.Api;
using Rosette.Api.Models;

namespace examples
{
class AddressSimilarity
{
/// <summary>
/// RunEndpoint runs the example. By default the endpoint will be run against the Rosette Cloud Service.
/// An optional alternate URL may be provided, i.e. for an on-premise solution.
/// </summary>
/// <param name="apiKey">Required api key (obtained from Basis Technology)</param>
/// <param name="altUrl">Optional alternate URL</param>
private void RunEndpoint(string apiKey, string? altUrl = null)
{
try
{
ApiClient api = new ApiClient(apiKey);
if (!string.IsNullOrEmpty(altUrl))
{
api.UseAlternateURL(altUrl);
}

var add1 = new UnfieldedAddressRecord { Address = "160 Pennsylvana Avenue, Washington, D.C., 20500" };
var add2 = new FieldedAddressRecord(houseNumber: "1600", road: "Pennsylvania Ave N.W.", city: "Washington", state: "DC", postcode: "20500");


Rosette.Api.Endpoints.AddressSimilarity endpoint = new Rosette.Api.Endpoints.AddressSimilarity(add1, add2);

Response response = endpoint.Call(api);

//The results of the API call will come back in the form of a Dictionary
foreach (KeyValuePair<string, string> h in response.Headers)
{
Console.WriteLine(string.Format("{0}:{1}", h.Key, h.Value));
}
Console.WriteLine(response.ContentAsJson(pretty: true));
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
/// <summary>
/// Main is a simple entrypoint for command line calling of the endpoint examples
/// </summary>
/// <param name="args">Command line args, expects API Key, (optional) alt URL</param>
static void Main(string[] args)
{
if (args.Length != 0)
{
new AddressSimilarity().RunEndpoint(args[0], args.Length > 1 ? args[1] : null);
}
else
{
Console.WriteLine("An API Key is required");
}
}
}
}
13 changes: 9 additions & 4 deletions examples/Categories.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using rosette_api;
using Rosette.Api;
using Rosette.Api.Models;

namespace examples {
class Categories
Expand All @@ -11,16 +12,20 @@ class Categories
/// <param name="altUrl">Optional alternate URL</param>
private void RunEndpoint(string apiKey, string? altUrl =null) {
try {
RosetteAPI api = new RosetteAPI(apiKey);
ApiClient api = new ApiClient(apiKey);
if (!string.IsNullOrEmpty(altUrl)) {
api.UseAlternateURL(altUrl);
}
string categories_text_data = @"Sony Pictures is planning to shoot a good portion of the new ""Ghostbusters"" in Boston as well.";

CategoriesEndpoint endpoint = new CategoriesEndpoint(categories_text_data);
Rosette.Api.Endpoints.Categories endpoint = new Rosette.Api.Endpoints.Categories(categories_text_data);

RosetteResponse response = endpoint.Call(api);
Response response = endpoint.Call(api);
//The results of the API call will come back in the form of a Dictionary
foreach (KeyValuePair<string, string> h in response.Headers)
{
Console.WriteLine(string.Format("{0}:{1}", h.Key, h.Value));
}
Console.WriteLine(response.ContentAsJson(pretty: true));
}
catch (Exception e) {
Expand Down
8 changes: 4 additions & 4 deletions examples/ConcurrencyTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using rosette_api;
using Rosette.Api;

namespace examples {
public class ConcurrencyTest {
Expand All @@ -15,7 +15,7 @@ public class ConcurrencyTest {
/// <param name="altUrl">Optional alternate URL</param>
private static async Task TestConcurrency(string apiKey, string altUrl) {
var tasks = new List<Task>();
RosetteAPI api = new RosetteAPI(apiKey);
ApiClient api = new ApiClient(apiKey);
if (!string.IsNullOrEmpty(altUrl)) {
api.UseAlternateURL(altUrl);
}
Expand All @@ -29,9 +29,9 @@ private static async Task TestConcurrency(string apiKey, string altUrl) {
Console.WriteLine("Test complete");
}

private static Task runLookup(int taskId, RosetteAPI api) {
private static Task runLookup(int taskId, ApiClient api) {
string entities_text_data = @"The Securities and Exchange Commission today announced the leadership of the agency’s trial unit. Bridget Fitzpatrick has been named Chief Litigation Counsel of the SEC and David Gottesman will continue to serve as the agency’s Deputy Chief Litigation Counsel. Since December 2016, Ms. Fitzpatrick and Mr. Gottesman have served as Co-Acting Chief Litigation Counsel. In that role, they were jointly responsible for supervising the trial unit at the agency’s Washington D.C. headquarters as well as coordinating with litigators in the SEC’s 11 regional offices around the country.";
EntitiesEndpoint endpoint = new EntitiesEndpoint(entities_text_data);
Rosette.Api.Endpoints.Entities endpoint = new Rosette.Api.Endpoints.Entities(entities_text_data);
foreach (int call in Enumerable.Range(0, calls)) {
Console.WriteLine("Task ID: {0} call {1}", taskId, call);
try {
Expand Down
9 changes: 5 additions & 4 deletions examples/Entities.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using rosette_api;
using Rosette.Api;
using Rosette.Api.Models;

namespace examples {
class Entities
Expand All @@ -11,14 +12,14 @@ class Entities
/// <param name="altUrl">Optional alternate URL</param>
private void RunEndpoint(string apiKey, string? altUrl =null) {
try {
RosetteAPI api = new RosetteAPI(apiKey);
ApiClient api = new ApiClient(apiKey);
if (!string.IsNullOrEmpty(altUrl)) {
api.UseAlternateURL(altUrl);
}
string entities_text_data = @"The Securities and Exchange Commission today announced the leadership of the agency’s trial unit. Bridget Fitzpatrick has been named Chief Litigation Counsel of the SEC and David Gottesman will continue to serve as the agency’s Deputy Chief Litigation Counsel. Since December 2016, Ms. Fitzpatrick and Mr. Gottesman have served as Co-Acting Chief Litigation Counsel. In that role, they were jointly responsible for supervising the trial unit at the agency’s Washington D.C. headquarters as well as coordinating with litigators in the SEC’s 11 regional offices around the country.";

EntitiesEndpoint endpoint = new EntitiesEndpoint(entities_text_data).SetGenre("social-media");
RosetteResponse response = endpoint.Call(api);
Rosette.Api.Endpoints.Entities endpoint = new Rosette.Api.Endpoints.Entities(entities_text_data).SetGenre("social-media");
Response response = endpoint.Call(api);

// Print out the response headers
foreach (KeyValuePair<string, string> h in response.Headers) {
Expand Down
52 changes: 52 additions & 0 deletions examples/Events.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Rosette.Api;
using Rosette.Api.Models;

namespace examples {
class Events
{
/// <summary>
/// RunEndpoint runs the example. By default the endpoint will be run against the Rosette Cloud Service.
/// An optional alternate URL may be provided, i.e. for an on-premise solution.
/// </summary>
/// <param name="apiKey">Required api key (obtained from Basis Technology)</param>
/// <param name="altUrl">Optional alternate URL</param>
private void RunEndpoint(string apiKey, string? altUrl = null) {
try {
ApiClient api = new ApiClient(apiKey);
if (!string.IsNullOrEmpty(altUrl)) {
api.UseAlternateURL(altUrl);
}
string events_text_data = @"I am looking for flights to Super Bowl 2022 in Inglewood, LA.";

Rosette.Api.Endpoints.Events endpoint = new Rosette.Api.Endpoints.Events(events_text_data);
Response response = endpoint.Call(api);

// Print out the response headers
foreach (KeyValuePair<string, string> h in response.Headers) {
Console.WriteLine(string.Format("{0}:{1}", h.Key, h.Value));
}
// Print out the content in JSON format. The Content property returns an IDictionary.
Console.WriteLine(response.ContentAsJson(pretty: true));

// Retrieve the Events with full ADM
response = endpoint.SetUrlParameter("output", "rosette").Call(api);
Console.WriteLine(response.ContentAsJson(pretty: true));
}
catch (Exception e) {
Console.WriteLine("Exception: " + e.Message);
}
}
/// <summary>
/// Main is a simple entrypoint for command line calling of the endpoint examples
/// </summary>
/// <param name="args">Command line args, expects API Key, (optional) alt URL</param>
static void Main(string[] args) {
if (args.Length != 0) {
new Events().RunEndpoint(args[0], args.Length > 1 ? args[1] : null);
}
else {
Console.WriteLine("An API Key is required");
}
}
}
}
9 changes: 5 additions & 4 deletions examples/Info.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using rosette_api;
using Rosette.Api;
using Rosette.Api.Models;

namespace examples {
class Info
Expand All @@ -11,12 +12,12 @@ class Info
/// <param name="altUrl">Optional alternate URL</param>
private void RunEndpoint(string apiKey, string? altUrl =null) {
try {
RosetteAPI api = new RosetteAPI(apiKey);
ApiClient api = new ApiClient(apiKey);
if (!string.IsNullOrEmpty(altUrl)) {
api.UseAlternateURL(altUrl);
}
InfoEndpoint endpoint = new InfoEndpoint();
RosetteResponse response = endpoint.Call(api);
Rosette.Api.Endpoints.Info endpoint = new Rosette.Api.Endpoints.Info();
Response response = endpoint.Call(api);

foreach (KeyValuePair<string, string> h in response.Headers) {
Console.WriteLine(string.Format("{0}:{1}", h.Key, h.Value));
Expand Down
9 changes: 5 additions & 4 deletions examples/Language.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using rosette_api;
using Rosette.Api;
using Rosette.Api.Models;

namespace examples {
class Language
Expand All @@ -11,7 +12,7 @@ class Language
/// <param name="altUrl">Optional alternate URL</param>
private void RunEndpoint(string apiKey, string? altUrl =null) {
try {
RosetteAPI api = new RosetteAPI(apiKey);
ApiClient api = new ApiClient(apiKey);
if (!string.IsNullOrEmpty(altUrl)) {
api.UseAlternateURL(altUrl);
}
Expand All @@ -20,9 +21,9 @@ private void RunEndpoint(string apiKey, string? altUrl =null) {

string language_data = @"Por favor Señorita, says the man.";

LanguageEndpoint endpoint = new LanguageEndpoint(language_data);
Rosette.Api.Endpoints.Language endpoint = new Rosette.Api.Endpoints.Language(language_data);
//The results of the API call will come back in the form of a Dictionary
RosetteResponse response = endpoint.Call(api);
Response response = endpoint.Call(api);
foreach (KeyValuePair<string, string> h in response.Headers) {
Console.WriteLine(string.Format("{0}:{1}", h.Key, h.Value));
}
Expand Down
9 changes: 5 additions & 4 deletions examples/LanguageMultilingual.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using rosette_api;
using Rosette.Api;
using Rosette.Api.Models;

namespace examples {
class LanguageMultilingual
Expand All @@ -11,16 +12,16 @@ class LanguageMultilingual
/// <param name="altUrl">Optional alternate URL</param>
private void RunEndpoint(string apiKey, string? altUrl =null) {
try {
RosetteAPI api = new RosetteAPI(apiKey);
ApiClient api = new ApiClient(apiKey);
if (!string.IsNullOrEmpty(altUrl)) {
api.UseAlternateURL(altUrl);
}
string language_multilingual_data = @"On Thursday, as protesters gathered in Washington D.C., the United States Federal Communications Commission under Chairman Ajit Pai voted 3-2 to overturn a 2015 decision, commonly called Net Neutrality, that forbade Internet service providers (ISPs) such as Verizon, Comcast, and AT&T from blocking individual websites or charging websites or customers more for faster load times. Quatre femmes ont été nommées au Conseil de rédaction de la loi du Qatar. Jeudi, le décret royal du Qatar a annoncé que 28 nouveaux membres ont été nommés pour le Conseil de la Choura du pays. ذكرت مصادر أمنية يونانية، أن 9 موقوفين من منظمة ""د هـ ك ب ج"" الذين كانت قد أوقفتهم الشرطة اليونانية في وقت سابق كانوا يخططون لاغتيال الرئيس التركي رجب طيب أردوغان.";

LanguageEndpoint endpoint = new LanguageEndpoint(language_multilingual_data).SetOption("multilingual", true);
Rosette.Api.Endpoints.Language endpoint = new Rosette.Api.Endpoints.Language(language_multilingual_data).SetOption("multilingual", true);

//The results of the API call will come back in the form of a Dictionary
RosetteResponse response = endpoint.Call(api);
Response response = endpoint.Call(api);
foreach (KeyValuePair<string, string> h in response.Headers) {
Console.WriteLine(string.Format("{0}:{1}", h.Key, h.Value));
}
Expand Down
10 changes: 6 additions & 4 deletions examples/MorphologyComplete.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using rosette_api;
using Rosette.Api;
using Rosette.Api.Endpoints;
using Rosette.Api.Models;

namespace examples {
class MorphologyComplete
Expand All @@ -11,15 +13,15 @@ class MorphologyComplete
/// <param name="altUrl">Optional alternate URL</param>
private void RunEndpoint(string apiKey, string? altUrl =null) {
try {
RosetteAPI api = new RosetteAPI(apiKey);
ApiClient api = new ApiClient(apiKey);
if (!string.IsNullOrEmpty(altUrl)) {
api.UseAlternateURL(altUrl);
}
string morphology_complete_data = @"The quick brown fox jumped over the lazy dog. 👍🏾 Yes he did. B)";
//The results of the API call will come back in the form of a Dictionary
MorphologyEndpoint endpoint = new MorphologyEndpoint(morphology_complete_data, MorphologyFeature.complete);
Morphology endpoint = new Morphology(morphology_complete_data, MorphologyFeature.complete);

RosetteResponse response = endpoint.Call(api);
Response response = endpoint.Call(api);
foreach (KeyValuePair<string, string> h in response.Headers) {
Console.WriteLine(string.Format("{0}:{1}", h.Key, h.Value));
}
Expand Down
12 changes: 7 additions & 5 deletions examples/MorphologyCompoundComponents.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using rosette_api;
using Rosette.Api;
using Rosette.Api.Endpoints;
using Rosette.Api.Models;

namespace rosette_apiExamples {
namespace Rosette.ApiExamples {
class MorphologyCompoundComponents
{
/// <summary>
Expand All @@ -11,14 +13,14 @@ class MorphologyCompoundComponents
/// <param name="altUrl">Optional alternate URL</param>
private void RunEndpoint(string apiKey, string? altUrl =null) {
try {
RosetteAPI api = new RosetteAPI(apiKey);
ApiClient api = new ApiClient(apiKey);
if (!string.IsNullOrEmpty(altUrl)) {
api.UseAlternateURL(altUrl);
}
string morphology_compound_components_data = @"Rechtsschutzversicherungsgesellschaften";
//The results of the API call will come back in the form of a Dictionary
MorphologyEndpoint endpoint = new MorphologyEndpoint(morphology_compound_components_data, MorphologyFeature.compoundComponents);
RosetteResponse response = endpoint.Call(api);
Morphology endpoint = new Morphology(morphology_compound_components_data, MorphologyFeature.compoundComponents);
Response response = endpoint.Call(api);
foreach (KeyValuePair<string, string> h in response.Headers) {
Console.WriteLine(string.Format("{0}:{1}", h.Key, h.Value));
}
Expand Down
10 changes: 6 additions & 4 deletions examples/MorphologyHanReadings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using rosette_api;
using Rosette.Api;
using Rosette.Api.Endpoints;
using Rosette.Api.Models;

namespace examples {
class MorphologyHanReadings
Expand All @@ -12,13 +14,13 @@ class MorphologyHanReadings
private void RunEndpoint(string apiKey, string? altUrl =null) {
try
{
RosetteAPI api = new RosetteAPI(apiKey);
ApiClient api = new ApiClient(apiKey);
if (!string.IsNullOrEmpty(altUrl)) {
api.UseAlternateURL(altUrl);
}
string morphology_han_readings_data = @"北京大学生物系主任办公室内部会议";
MorphologyEndpoint endpoint = new MorphologyEndpoint(morphology_han_readings_data, MorphologyFeature.hanReadings);
RosetteResponse response = endpoint.Call(api);
Morphology endpoint = new Morphology(morphology_han_readings_data, MorphologyFeature.hanReadings);
Response response = endpoint.Call(api);
foreach (KeyValuePair<string, string> h in response.Headers) {
Console.WriteLine(string.Format("{0}:{1}", h.Key, h.Value));
}
Expand Down
11 changes: 7 additions & 4 deletions examples/MorphologyLemmas.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using rosette_api;
using Rosette.Api;
using Rosette.Api.Endpoints;
using Rosette.Api.Models;

namespace examples {
class MorphologyLemmas
Expand All @@ -11,14 +13,15 @@ class MorphologyLemmas
/// <param name="altUrl">Optional alternate URL</param>
private void RunEndpoint(string apiKey, string? altUrl =null) {
try {
RosetteAPI api = new RosetteAPI(apiKey);
ApiClient api = new ApiClient(apiKey);
if (!string.IsNullOrEmpty(altUrl)) {
api.UseAlternateURL(altUrl);
}
string morphology_lemmas_data = @"The fact is that the geese just went back to get a rest and I'm not banking on their return soon";
//The results of the API call will come back in the form of a Dictionary
MorphologyEndpoint endpoint = new MorphologyEndpoint(morphology_lemmas_data, MorphologyFeature.lemmas);
RosetteResponse response = endpoint.Call(api);
Morphology endpoint = new Morphology(morphology_lemmas_data, MorphologyFeature.lemmas);
Response response = endpoint.Call(api);

foreach (KeyValuePair<string, string> h in response.Headers) {
Console.WriteLine(string.Format("{0}:{1}", h.Key, h.Value));
}
Expand Down
Loading