parse(str = "") {
        const self = this;
        return new Promise((resolve, reject) => {
            const paramJson = {
                appid: self._appId,
                sentence: str,
                results: "ma"
            };
            axios({
                method: "post",
                url: API_URL,
                data: querystring.stringify(paramJson),
                timeout: self._timeout
            })
                .then((res) => {
                    const result = [];
                    const resObj = xmlParser.parse(res.data, {
                        trimValues: false // in case of the whitespace character
                    });
                    if (resObj.ResultSet.ma_result.total_count === 0) return resolve(result);
                    if (resObj.ResultSet.ma_result.total_count === 1) {
                        result.push({
                            surface_form: resObj.ResultSet.ma_result.word_list.word.surface,
                            pos: resObj.ResultSet.ma_result.word_list.word.pos,
                            reading: resObj.ResultSet.ma_result.word_list.word.reading
                        });
                    }
                    else {
                        for (let i = 0; i < resObj.ResultSet.ma_result.word_list.word.length; i++) {
                            result.push({
                                surface_form: resObj.ResultSet.ma_result.word_list.word[i].surface,
                                pos: resObj.ResultSet.ma_result.word_list.word[i].pos,
                                reading: resObj.ResultSet.ma_result.word_list.word[i].reading
                            });
                        }
                    }
                    resolve(result);
                })
                .catch((err) => {
                    reject(err);
                });
        });
    }
/**
     * Parse the given string
     * @param {*} str input string
     * @returns {Promise} Promise object represents the result of parsing
     */
Parse the given string
@param {*} str input string
@returns {Promise} Promise object represents the result of parsing
Parse the given string @param { * } str input string @returns { Promise } Promise object represents the result of parsing
parse(str = "") {
        const self = this;
        return new Promise((resolve, reject) => {
            const paramJson = {
                appid: self._appId,
                sentence: str,
                results: "ma"
            };
            axios({
                method: "post",
                url: API_URL,
                data: querystring.stringify(paramJson),
                timeout: self._timeout
            })
                .then((res) => {
                    const result = [];
                    const resObj = xmlParser.parse(res.data, {
                        trimValues: false 
                    });
                    if (resObj.ResultSet.ma_result.total_count === 0) return resolve(result);
                    if (resObj.ResultSet.ma_result.total_count === 1) {
                        result.push({
                            surface_form: resObj.ResultSet.ma_result.word_list.word.surface,
                            pos: resObj.ResultSet.ma_result.word_list.word.pos,
                            reading: resObj.ResultSet.ma_result.word_list.word.reading
                        });
                    }
                    else {
                        for (let i = 0; i < resObj.ResultSet.ma_result.word_list.word.length; i++) {
                            result.push({
                                surface_form: resObj.ResultSet.ma_result.word_list.word[i].surface,
                                pos: resObj.ResultSet.ma_result.word_list.word[i].pos,
                                reading: resObj.ResultSet.ma_result.word_list.word[i].reading
                            });
                        }
                    }
                    resolve(result);
                })
                .catch((err) => {
                    reject(err);
                });
        });
    }
parse ( str = "" ) { const self = this ; return new Promise ( ( resolve , reject ) => { const paramJson = { appid : self . _appId , sentence : str , results : "ma" } ; axios ( { method : "post" , url : API_URL , data : querystring . stringify ( paramJson ) , timeout : self . _timeout } ) . then ( ( res ) => { const result = [ ] ; const resObj = xmlParser . parse ( res . data , { trimValues : false } ) ; if ( resObj . ResultSet . ma_result . total_count === 0 ) return resolve ( result ) ; if ( resObj . ResultSet . ma_result . total_count === 1 ) { result . push ( { surface_form : resObj . ResultSet . ma_result . word_list . word . surface , pos : resObj . ResultSet . ma_result . word_list . word . pos , reading : resObj . ResultSet . ma_result . word_list . word . reading } ) ; } else { for ( let i = 0 ; i < resObj . ResultSet . ma_result . word_list . word . length ; i ++ ) { result . push ( { surface_form : resObj . ResultSet . ma_result . word_list . word [ i ] . surface , pos : resObj . ResultSet . ma_result . word_list . word [ i ] . pos , reading : resObj . ResultSet . ma_result . word_list . word [ i ] . reading } ) ; } } resolve ( result ) ; } ) . catch ( ( err ) => { reject ( err ) ; } ) ; } ) ; }
Parse the given string
 @param {*} str input string
 @returns {Promise} Promise object represents the result of parsing
Parse the given string @param { * } str input string @returns { Promise } Promise object represents the result of parsing
// in case of the whitespace character