/**
         * @brief Event when "Get result" button is clicked.
         */
        public async void CreateClicked(object sender, EventArgs args)
        {
            Button button = (Button)sender;

            InputLabel.Text = Comment;
            float[] input;
            float[] output = new float[2];

            /* Initialize the model */
            TextModel.init_model();
            /* Convert user input to float array */
            input = TextModel.SplitStr(Comment);

            if (string.IsNullOrEmpty(Comment))
            {
                Log.Warn(TAG, "User input is empty");
                /* Check wrong Input parameter */
                await DisplayAlert("Error!", "Please enter your comment", "OK");
            }
            else if (Equals(button.Text, "Single-shot"))
            {
                /*Invoke the model */
                API.Text = "Single-shot";
                output   = TextModel.invoke_mode(input);
            }
            else if (Equals(button.Text, "Pipeline"))
            {
                Log.Warn(TAG, "Unsupported API");
                await DisplayAlert("Error!", "Pipeline API will be supported soon.", "OK");
            }
            else
            {
                Log.Error(TAG, "Unknown button is pressed");
            }

            /* Show text classification resut */
            if (output[0].Equals(0) && output[1].Equals(0))
            {
                Out_neg.Text = "Invalid result";
                Out_pos.Text = "InValid result";
            }
            else
            {
                Out_neg.Text = output[0].ToString();
                Out_pos.Text = output[1].ToString();
            }
        }
Exemple #2
0
        /// <summary>
        /// Event when "Get result" button is clicked.
        /// </summary>
        /// <param name="sender">Instance of the object which invokes event.</param>
        /// <param name="args"> Event argument.</param>
        public async void CreateClicked(object sender, EventArgs args)
        {
            Button button = (Button)sender;

            InputLabel.Text = UserCommentEntry.Text;
            float[] input;
            float[] output = new float[2];

            /// Initialize the model
            TextModel.Init_model();
            /// Convert user input to float array
            input = TextModel.SplitStr(UserCommentEntry.Text);

            if (string.IsNullOrEmpty(UserCommentEntry.Text))
            {
                Log.Warn(TAG, "User input is empty");
                /// Check wrong Input parameter
                await DisplayAlert("Error!", "Please enter your comment", "OK");

                return;
            }
            else
            {
                /// Invoke the model
                API.Text = "Single-shot";
                output   = TextModel.Invoke_model(input);
            }

            /// Show text classification resut
            if (output[0].Equals(0) && output[1].Equals(0))
            {
                Out_neg.Text = "Invalid result";
                Out_pos.Text = "InValid result";
            }
            else
            {
                Out_neg.Text = output[0].ToString();
                Out_pos.Text = output[1].ToString();
            }
        }