Skip to content

Commit 0c96a71

Browse files
authored
Merge pull request #378 from watson-developer-cloud/6840-regular-sdk-relelase
Regular SDK Relelase #3
2 parents e7da179 + fe918d4 commit 0c96a71

File tree

60 files changed

+5147
-5267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+5147
-5267
lines changed

appveyor.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,6 @@ test_script:
269269
270270
dotnet pack .\src\IBM.Watson.VisualRecognition.v3\IBM.Watson.VisualRecognition.v3.csproj --configuration Release
271271
272-
dotnet pack .\src\IBM.Watson.Common\IBM.Watson.Common.csproj --configuration Release
273-
274272
}
275273
276274
@@ -299,8 +297,6 @@ artifacts:
299297
name: IBM.Watson.NaturalLanguageUnderstanding.v1
300298
- path: '\src\IBM.Watson.NaturalLanguageClassifier.v1\bin\$(configuration)\*.nupkg'
301299
name: IBM.Watson.NaturalLanguageClassifier.v1
302-
- path: '\src\IBM.Watson.Common\bin\$(configuration)\*.nupkg'
303-
name: IBM.Watson.Common
304300
deploy:
305301
- provider: NuGet
306302
api_key:

examples/IBM.Watson.LanguageTranslator.v3.Examples/IBM.Watson.LanguageTranslator.v3.Examples.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17-
<None Update="appsettings.json;.\glossary.tmx">
17+
<None Update="appsettings.json;.\LanguageTranslatorTestData\**\*">
1818
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
1919
</None>
2020
</ItemGroup>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Where is the library?
2+
How are you?

examples/IBM.Watson.LanguageTranslator.v3.Examples/ServiceExample.cs

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ public class ServiceExample
2929
string apikey = "{apikey}";
3030
string url = "{url}";
3131
string versionDate = "{versionDate}";
32-
private string glossaryPath = "glossary.tmx";
32+
private static string glossaryPath = "LanguageTranslatorTestData/glossary.tmx";
33+
private static string documentToTranslatePath = "LanguageTranslatorTestData/document-to-translate.txt";
3334
private string modelId;
35+
private string documentId;
3436

3537
static void Main(string[] args)
3638
{
@@ -43,6 +45,11 @@ static void Main(string[] args)
4345
example.CreateModel();
4446
example.GetModel();
4547
example.DeleteModel();
48+
example.ListDocuments();
49+
example.TranslateDocument();
50+
example.GetDocumentStatus();
51+
example.GetTranslatedDocument();
52+
example.DeleteDocument();
4653

4754
Console.WriteLine("Examples complete. Press any key to close the application.");
4855
Console.ReadKey();
@@ -181,5 +188,103 @@ public void DeleteModel()
181188
Console.WriteLine(result.Response);
182189
}
183190
#endregion
191+
192+
#region Documents
193+
public void ListDocuments()
194+
{
195+
TokenOptions tokenOptions = new TokenOptions()
196+
{
197+
IamApiKey = apikey,
198+
ServiceUrl = url
199+
};
200+
201+
LanguageTranslatorService service = new LanguageTranslatorService(tokenOptions, versionDate);
202+
203+
var result = service.ListDocuments();
204+
205+
Console.WriteLine(result.Response);
206+
}
207+
208+
public void TranslateDocument()
209+
{
210+
TokenOptions tokenOptions = new TokenOptions()
211+
{
212+
IamApiKey = apikey,
213+
ServiceUrl = url
214+
};
215+
216+
LanguageTranslatorService service = new LanguageTranslatorService(tokenOptions, versionDate);
217+
218+
DetailedResponse<DocumentStatus> result;
219+
220+
using (FileStream fs = File.OpenRead(documentToTranslatePath))
221+
{
222+
using (MemoryStream ms = new MemoryStream())
223+
{
224+
fs.CopyTo(ms);
225+
result = service.TranslateDocument(
226+
file: ms,
227+
filename: Path.GetFileName(documentToTranslatePath),
228+
fileContentType: "text/plain",
229+
modelId: "en-es"
230+
);
231+
}
232+
}
233+
234+
Console.WriteLine(result.Response);
235+
documentId = result.Result.DocumentId;
236+
}
237+
238+
public void GetDocumentStatus()
239+
{
240+
TokenOptions tokenOptions = new TokenOptions()
241+
{
242+
IamApiKey = apikey,
243+
ServiceUrl = url
244+
};
245+
246+
LanguageTranslatorService service = new LanguageTranslatorService(tokenOptions, versionDate);
247+
248+
var result = service.GetDocumentStatus(
249+
documentId: documentId
250+
);
251+
252+
Console.WriteLine(result.Response);
253+
}
254+
255+
public void DeleteDocument()
256+
{
257+
TokenOptions tokenOptions = new TokenOptions()
258+
{
259+
IamApiKey = apikey,
260+
ServiceUrl = url
261+
};
262+
263+
LanguageTranslatorService service = new LanguageTranslatorService(tokenOptions, versionDate);
264+
265+
var result = service.DeleteDocument(
266+
documentId: documentId
267+
);
268+
269+
Console.WriteLine(result.StatusCode);
270+
}
271+
272+
public void GetTranslatedDocument()
273+
{
274+
TokenOptions tokenOptions = new TokenOptions()
275+
{
276+
IamApiKey = apikey,
277+
ServiceUrl = url
278+
};
279+
280+
LanguageTranslatorService service = new LanguageTranslatorService(tokenOptions, versionDate);
281+
282+
var result = service.GetTranslatedDocument(
283+
documentId: documentId
284+
);
285+
286+
Console.WriteLine(result.Response);
287+
}
288+
#endregion
184289
}
185290
}

0 commit comments

Comments
 (0)