搜尋套件、儲存庫與 APP 分類

GitHub 儲存庫rishabnayak/firebase_mlkit_language

firebase_mlkit_language

適用於 Flutter 的 Firebase ML Kit 語言外掛程式

firebase_mlkit_language 專案封面
星標
18
分支
21
最近推送(UTC)
2020年10月26日
專案狀態
未封存

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

ML Kit Natural Language Plugin

Pub

A Flutter plugin to use the ML Kit Natural Language for Firebase API.

For Flutter plugins for other Firebase products, see FlutterFire.md.

Note: This plugin is still under development, and some APIs might not be available yet. Feedback and Pull Requests are most welcome!

Usage

To use this plugin, add firebase_mlkit_language as a dependency in your pubspec.yaml file. You must also configure Firebase for each platform project: Android and iOS (see the example folder or https://codelabs.developers.google.com/codelabs/flutter-firebase/#4 for step by step details).

iOS

Versions 1.0.0+ use the latest ML Kit for Firebase version which requires a minimum deployment target of 9.0. You can add the line platform :ios, '9.0' in your iOS project Podfile.

Supported Languages

All the supported languages can be found here.

Furthermore, they can be found within the SupportedLanguages class.

Using the ML Kit Language Identifier

1. Create an instance of a language identifier

Initialize a LanguageIdentifier.

final LanguageIdentifier languageIdentifier = FirebaseLanguage.instance.languageIdentifier()
2. Call processText(String) with languageIdentifier

processText(String) returns List<LanguageLabel> in decreasing order of probability of detected language.

final List<LanguageLabel> labels = await languageIdentifier.processText('Sample Text');
3. Extract data

<LanguageLabel> contains the language names and confidence of the prediction, accessible via .text and .confidence.

for (LanguageLabel label in labels) {
  final String text = label.text;
  final double confidence = label.confidence;
}

Using the ML Kit Language Translator

Note

Get an instance of ModelManager, and download the needed translation models(optional, results in faster first-use).

FirebaseLanguage.instance.modelManager().downloadModel(SupportedLanguages.lang);
1. Create an instance of a language translator

Initialize a LanguageTranslator.

final FirebaseLanguage.instance.languageTranslator(SupportedLanguages.lang, SupportedLanguages.lang);
2. Call processText(String) with languageTranslator

processText(String) returns a string containing the text translated to the target language.

final String translatedString = await languageTranslator.processText('Sample Text');

Using the ML Kit Model Manager

1. Create an instance of a model manager

Initialize a ModelManager

final ModelManager modelManager = FirebaseLanguage.instance.modelManager()
2. Download Model using the model manager

downloadModel() downloads the specified model to the device's local storage. It is recommended to download all the models needed to be used before translating to ensure a fast first-use. On a successful download, the string "Downloaded" will be returned.

modelManager.downloadModel(SupportedLanguages.lang)
3. Delete Model using the model manager

deleteModel() deletes the specified model from the device's local storage. On a successful delete, the string "Deleted" will be returned. If the model specified is not present on the device, the string "Model not downloaded" will be returned.

modelManager.deleteModel(SupportedLanguages.lang)
4. View Models

viewModels() returns a list of the BCP-47 language codes of all the languages downloaded onto the local storage of the device.

modelManager.viewModels()
Rishab Nayak GitHub avatar
GitHub 作者

Rishab Nayak ↗

Serial Founder | Prev: Mount ($3M+, GC)

@videahealthBoston, Massachusetts
語言DartJavaObjective-CRuby

使用的依賴

依賴清單 5 項

  • flutter{"sdk":"flutter"}
  • flutter_test開發依賴{"sdk":"flutter"}
  • flutter_driver開發依賴{"sdk":"flutter"}
  • firebase_core開發依賴^0.4.0
  • test開發依賴any

如何選擇適合專案的儲存庫?

先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。

  1. 透過儲存庫名稱、作者或描述搜尋,再依技術分類縮小範圍。
  2. 綜合星標、分支與最近推送比較專案;星標反映社群關注,不保證品質。
  3. 使用前在 GitHub 確認 README、授權條款與 Issues。

來源與維護

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗