R/commLTP.R

commLTP = function(input, mission = 'ws', api_key)
{
    addr = 'http://api.ltp-cloud.com/analysis/'
    if(mission=='ws')
        return_format = 'plain'
    else
        return_format = 'json'
    result = postForm(uri = addr,
                      style = "post",
                      'text' = input,
                      'api_key' = api_key,
                      'pattern' = mission,
                      'format' = return_format)

    Encoding(result)='UTF-8'
    if (return_format!='plain')
    {
        if (Sys.info()['sysname']=='Windows')
            result = iconv(result,'UTF-8','GBK')
        return(result)
    }
    
    result = parseLTP(result)
    result
}

Try the rLTP package in your browser

Any scripts or data that you put into this service are public.

rLTP documentation built on May 2, 2019, 8:29 a.m.