Example usage for com.google.gwt.language.client.translation LangDetResult confidence

List of usage examples for com.google.gwt.language.client.translation LangDetResult confidence

Introduction

In this page you can find the example usage for com.google.gwt.language.client.translation LangDetResult confidence.

Prototype

public final native double confidence() ;

Source Link

Document

Returns a numeric value between 0-1.0 that represents the confidence level in the language code for the given text.

Usage

From source file:com.google.gwt.language.sample.hellolanguage.client.LanguageDetectionDemo.java

License:Apache License

/**
 * Creates a "Detect" button to do language detection.
 *
 * @return button/*  w  w  w.ja v a  2 s. com*/
 */
private Button createLanguageDetectionButton() {
    Button langDetButton = new Button("Detect");
    langDetButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Translation.detect(inputTextArea.getText(), new LangDetCallback() {
                @Override
                protected void onCallback(LangDetResult result) {
                    outputDiv.setText("Detected language: " + result.getLanguage() + ", Confidence: "
                            + result.confidence());
                }
            });
        }
    });
    return langDetButton;
}