Skip to content

Commit

Permalink
Merge pull request #3 from bb-io/develop
Browse files Browse the repository at this point in the history
Updated response display translation text
  • Loading branch information
RiabushenkoA authored Jan 8, 2025
2 parents a56862e + da0e659 commit 2dcc9cb
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 38 deletions.
7 changes: 6 additions & 1 deletion Apps.Systran/Actions/TranslateTextActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ public async Task<TranslateTextResponse> TranslateText([ActionParameter] Transla
if (input.BackTranslation.HasValue)
request.AddQueryParameter("backTranslation", input.BackTranslation.Value.ToString().ToLower());

var response = await Client.ExecuteWithErrorHandling<TranslateTextResponse>(request);
var systranResponse = await Client.ExecuteWithErrorHandling<TranslateText>(request);

var response = new TranslateTextResponse
{
Output = systranResponse.Outputs.FirstOrDefault()?.Output ?? string.Empty
};
return response;
}

Expand Down
2 changes: 1 addition & 1 deletion Apps.Systran/Apps.Systran.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<Product>Systran [Beta]</Product>
<Description>SYSTRAN Translate API is built around a RESTful API and can be used in all types of applications.This API Reference is intended for developers who want to write applications that can interact with the SYSTRAN Translate API. You can integrate our translation technology directly in your internal or external applications to make them multilingual or translate texts and files by using the SYSTRAN Translate API.</Description>
<Version>1.0.2</Version>
<Version>1.0.3</Version>

<AssemblyName>Apps.Systran</AssemblyName>
</PropertyGroup>
Expand Down
44 changes: 44 additions & 0 deletions Apps.Systran/Models/Response/TranslateText.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Blackbird.Applications.Sdk.Common;

namespace Apps.Systran.Models.Response
{
public class TranslateText
{
[Display("Request ID")]
public string RequestId { get; set; } = string.Empty;

[Display("Outputs")]
public List<TranslationOutput> Outputs { get; set; } = new();
}

public class TranslationOutput
{
[Display("Info")]
public TranslationInfo? Info { get; set; }

[Display("Translated text")]
public string Output { get; set; } = string.Empty;

[Display("Back translation")]
public string? BackTranslation { get; set; }

[Display("Source text")]
public string? Source { get; set; }
}

public class TranslationInfo
{
[Display("Language identification")]
public LanguageIdentification? Lid { get; set; }

}

public class LanguageIdentification
{
[Display("Language")]
public string Language { get; set; } = string.Empty;

[Display("Confidence level")]
public float Confidence { get; set; }
}
}
42 changes: 6 additions & 36 deletions Apps.Systran/Models/Response/TranslateTextResponse.cs
Original file line number Diff line number Diff line change
@@ -1,44 +1,14 @@
using Blackbird.Applications.Sdk.Common;


using Blackbird.Applications.Sdk.Common;
using Newtonsoft.Json;

namespace Apps.Systran.Models.Response
{
public class TranslateTextResponse
{
[Display("Request ID")]
public string RequestId { get; set; } = string.Empty;

[Display("Outputs")]
public List<TranslationOutput> Outputs { get; set; } = new();
}

public class TranslationOutput
{
[Display("Info")]
public TranslationInfo? Info { get; set; }

[Display("Translated text")]
public string Output { get; set; } = string.Empty;

[Display("Back translation")]
public string? BackTranslation { get; set; }

[Display("Source text")]
public string? Source { get; set; }
}

public class TranslationInfo
{
[Display("Language identification")]
public LanguageIdentification? Lid { get; set; }

}

public class LanguageIdentification
{
[Display("Language")]
public string Language { get; set; } = string.Empty;

[Display("Confidence level")]
public float Confidence { get; set; }
[JsonProperty("output")]
public string Output { get; set; }
}
}

0 comments on commit 2dcc9cb

Please sign in to comment.