This repository was archived by the owner on Apr 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
src/mlkit/naturallanguageidentification Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,11 @@ import {
77export function identifyNaturalLanguage ( options : MLKitNaturalLanguageIdentificationOptions ) : Promise < MLKitNaturalLanguageIdentificationResult > {
88 return new Promise ( ( resolve , reject ) => {
99 try {
10+ if ( ! options . text ) {
11+ reject ( "'text' property not set to a valid value" ) ;
12+ return ;
13+ }
14+
1015 const languageIdentifier : com . google . firebase . ml . naturallanguage . languageid . FirebaseLanguageIdentification =
1116 com . google . firebase . ml . naturallanguage . FirebaseNaturalLanguage . getInstance ( ) . getLanguageIdentification (
1217 new com . google . firebase . ml . naturallanguage . languageid . FirebaseLanguageIdentificationOptions . Builder ( )
Original file line number Diff line number Diff line change @@ -7,6 +7,11 @@ import {
77export function identifyNaturalLanguage ( options : MLKitNaturalLanguageIdentificationOptions ) : Promise < MLKitNaturalLanguageIdentificationResult > {
88 return new Promise ( ( resolve , reject ) => {
99 try {
10+ if ( ! options . text ) {
11+ reject ( "'text' property not set to a valid value" ) ;
12+ return ;
13+ }
14+
1015 const naturalLanguage = FIRNaturalLanguage . naturalLanguage ( ) ;
1116 const languageId = naturalLanguage . languageIdentificationWithOptions (
1217 FIRLanguageIdentificationOptions . alloc ( ) . initWithConfidenceThreshold ( options . confidenceThreshold || 0.5 ) ) ;
You can’t perform that action at this time.
0 commit comments