Invertase
Invertase

Notice: This documentation is currently a work in progress for the upcoming v6 release and some content may be missing or incomplete. If you're not interested in testing out the alpha version of v6 then please click here to be taken to the v5 documentation.

message  Send Feedback

ml-natural-language()

The Firebase ML Kit service interface.

This module is available for the default app only.

Example

Get the ML Kit service for the default app:

const defaultAppMLKit = firebase.mlKitLanguage();

Properties

app

app: FirebaseApp;

Methods

identifyLanguage

identifyLanguage(text: string, options?: LanguageIdentificationOptions): Promise<string>;

Identifies the main language for the given text.

Returns a promise that resolves with a BCP-47 language code of the detected language.

If the language was undetected or unknown the code returned is und.

Example

const language = await firebase.mlKitLanguage().identifyLanguage('Hello there. General Kenobi.');
console.warn(language); // en
const unknownLanguage = await firebase.mlKitLanguage().identifyLanguage('foo bar baz', { confidenceThreshold: 0.9 });
console.warn(language); // und
Parameters
  • text
    The input text to use for identifying the language. Inputs longer than 200 characters are truncated to 200 characters, as longer input does not improve the detection accuracy.
  • options
    See `LanguageIdentificationOptions`.

identifyPossibleLanguages

identifyPossibleLanguages(text: string, options?: LanguageIdentificationOptions): Promise<>;

Identifies possible languages for the given text.

Example

const identifiedLanguages = firebase.mlKitLanguage().identifyPossibleLanguages('hello world');
console.warn(identifiedLanguages[0].language); // en
Parameters
  • text
    The input text to use for identifying the language. Inputs longer than 200 characters are truncated to 200 characters, as longer input does not improve the detection accuracy.
  • options
    See `LanguageIdentificationOptions`.

newSmartReplyConversation

newSmartReplyConversation(messageHistoryLimit?: undefined | number): SmartReplyConversation;

Returns a new instance of SmartReplyConversation.

Example

const conversation = firebase.mlKitLanguage().newSmartReplyConversation();
Parameters
  • messageHistoryLimit
    Optional value to specify the number of messages to keep in history, messages in history are used with `SmartReplyConversation.getSuggestedReplies` and are sent natively every time this method is called. Defaults to 30.