BergamotTranslatorSharp 0.3.3
dotnet add package BergamotTranslatorSharp --version 0.3.3
NuGet\Install-Package BergamotTranslatorSharp -Version 0.3.3
<PackageReference Include="BergamotTranslatorSharp" Version="0.3.3" />
<PackageVersion Include="BergamotTranslatorSharp" Version="0.3.3" />
<PackageReference Include="BergamotTranslatorSharp" />
paket add BergamotTranslatorSharp --version 0.3.3
#r "nuget: BergamotTranslatorSharp, 0.3.3"
#addin nuget:?package=BergamotTranslatorSharp&version=0.3.3
#tool nuget:?package=BergamotTranslatorSharp&version=0.3.3
BergamotTranslatorSharp
BergamotTranslatorSharp is a C# wrapper for Bergamot Translator. It allows easy integration of an offline machine translation engine into .NET applications.
Overview
Bergamot Translator is an offline translation engine. The official website is https://browser.mt/. This library wraps its functionality for use from C#.
Features
- Offline translation capability
- Multi-language support
- Fast processing
- Easy integration with .NET applications
Installation
Installation from NuGet
Install-Package BergamotTranslatorSharp
Or
dotnet add package BergamotTranslatorSharp
Requirements
- .NET 6.0 or later
- .NET Standard 2.1 or later
- Windows x64 or Linux x64
Usage
Downloading Models and Creating Configuration Files
- Download and extract models from the Firefox Translations models official website.
cd test_page git clone --depth 1 --branch main --single-branch https://github.com/mozilla/firefox-translations-models/ mkdir models cp -rf firefox-translations-models/registry.json models cp -rf firefox-translations-models/models/prod/* models cp -rf firefox-translations-models/models/dev/* models gunzip models/*/*
- Create a configuration file in the same location as the binary file.
relative-paths: true models: - model.enja.intgemm.alphas.bin // model path vocabs: - vocab.enja.spm // source vocabulary path - vocab.enja.spm // target vocabulary path shortlist: - lex.50.50.enja.s2t.bin // shortlist path - false beam-size: 1 normalize: 1.0 word-penalty: 0 max-length-break: 128 mini-batch-words: 1024 workspace: 128 max-length-factor: 2.0 skip-cost: true cpu-threads: 0 quiet: true quiet-translation: true gemm-precision: int8shiftAlphaAll // specify 'int8shiftAlphaAll' if the model name contains 'alphas', otherwise specify 'int8shiftAll'
Initializing the Translation Service and Translating
using BergamotTranslatorSharp;
// Create an instance of BergamotTranslator
using var translator = new BergamotTranslator(configPath);
// Execute translation
string sourceText = "Hello, world!";
string translatedText = translator.Translate(sourceText);
Console.WriteLine(translatedText); // こんにちは、世界!
License
This project is released under the MPL-2.0 license.
Contribution
Please report bugs and feature requests to the GitHub Issue Tracker. Pull requests are also welcome.
Acknowledgments
This project is based on browsermt/bergamot-translator.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.