BookmarkSubscribeRSS Feed

[API] SAS HTTP 프로시져를 통한 네이버 파파고 기계번역 결과 반환 받기

Started ‎06-15-2020 by
Modified ‎06-15-2020 by
Views 248

* 1. 한글 SAS config의 encoding을 "UTF-8" 변경 후 SAS 실행;

 

* 2. 파파고 기계번역 API 이용 신청 : Client ID 와 Client Secret 할당;

 

* 기계번역(Beta) API 명세: https://developers.naver.com/docs/labs/translator/;

 

 

 /* Create fileref to store POST parameters */

filename in "D:\업무지식자료\API 프로그램
aver\ProxyTest_in";

/* Create fileref to store http response */

*  encoding="UTF-8";

filename out "D:\업무지식자료\API 프로그램
aver\ProxyTest_out.txt";

 

 

%let client_id=네이버 개발자 사이트에서 할당된 사용자id;

%let client_secret=네이버 개발자 사이트에서 할당된 패스워드;

 

/* Write parameters to file */

/* source=en&target=ko&text=statistics analysis study. */

data _null_;

   file in;

   input;

   put _infile_;

   datalines4;

source=ko&target=zh-CN&text=통계분석연구회.

;;;;

run;

 

/* Run the request */

proc http 

     in     = in

     out    = out

     method = "POST"     

     url    = "https://openapi.naver.com/v1/language/translate"

     ct     = "application/x-www-form-urlencoded; charset=UTF-8";

 

     headers 

       "X-Naver-Client-Id"     = "&client_id"

       "X-Naver-Client-Secret" = "&client_secret";

run;

 

* 추출결과 확인;

data _null_;

     infile out encoding="UTF-8";

     input ;

     put _infile_;

run;

 

 

data test;

     infile out encoding="utf-8";

     input var : $200.;

run;

 

 

*******************************************************;

* 반환 결과;

 

{"message":{"@type":"response","@service":"naverservice.labs.api","@ve

rsion":"1.0.0","result":{"translatedText":"Korea Research Council of s

tatistical analysis.","srcLangType":"ko"}}}

 
 

 

* 인코딩 확인하기;

data test1; 

 x='占'; 

 y=getoption('encoding'); 

 put x=; 

 put y=; 

 put x $hex4.; 

run;

Version history
Last update:
‎06-15-2020 02:13 AM
Updated by:
Contributors

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Article Labels
Article Tags