Language Detection

  • Example request
    //You are advised to construct and use the client in a singleton pattern to avoid frequent object creation.
    MtClient client = new MtClient(AuthMode.AKSK,authInfo);
    
    LanguageDetectionReq req = new LanguageDetectionReq();
    
    //Content to be detected
    req.setText("Play the Qinghuaci of Jay Chou");
    
    try {
        LanguageDetectionResp resp = client.detectLanguage(req);
    } catch (NlpException e) {
        //A failure is thrown as an exception. For details about exceptions, see section "Exceptions". The client automatically processes exceptions.
    }
  • Table 1 describes LanguageDetectionReq parameters.
    Table 1 LanguageDetectionReq parameters

    Parameter

    Mandatory

    Type

    Description

    text

    Yes

    String

    Text to be detected

  • Table 2 describes LanguageDetectionResp parameters.
    Table 2 LanguageDetectionResp parameters

    Parameter

    Type

    Description

    detectedLanguage

    String

    Abbreviation of the detected language. For details about supported languages, see Table 3.

    Table 3 Supported languages

    Language

    Abbreviation

    Chinese

    zh

    English

    en

    Russian

    ru

    Japanese

    ja

    German

    de

    French

    fr

    Spanish

    es

    Portuguese

    pt

    Italian

    it

    Turkish

    tr

    Arabic

    ar