본 프로젝트에서는, TLDRThisAPI로 요약문을 추출한 뒤, Naver의 PapagoAPI를 사용하여 자동 번역해주는 모델을 만들고, 이를 제공하는 플랫폼을 구축하여 서비스하고자 한다. 하지만, TLDRThisAPI와 PapagoAPI는 무료 버전기준 한 달 최대 사용량이 제한되어있다. 따라서 개개인이 각각 개별적인 API 키를 갖도록하고, 로그인 시스템을 구현하여 개개인의 API 키를 보존함으로써 위 문제를 해결하고자 한다.

Reperence

이제현, 유시현, 김창기, 김현구, “Open API를 활용한 고속 논문 분석”, 실용인공지능학회지 vol.1 p.9, 2022

https://jehyunlee.github.io/2022/07/02/Python-DS-106-aaicon/

https://github.com/kairess/human-like-summarization-translation/


1. TLDRThis

1-1. API 키 발급

https://rapidapi.com/tldrthishq-tldrthishq-default/api/tldrthis/

TLDR은 Too Long Don’t Read의 줄임말로, 긴 글을 요약해주는 API이다. 요약 기법은 다음과 같이 크게 2개로 나뉘어진다.

  • Abstractive(Human-like) summarization

    Abstractive summarization(생성 요약)은 기존 Input text를 그대로 인용하지 않고, 기존의 내용을 새롭게 re-phrasing 하여 Summary를 생성하는 요약 모델입니다.

  • Extractive summarization

    반면에 Extractive summarization(추출 요약)은 기존 Input text에 존재하는 중요한 단어를 그대로 사용하여 Summary를 생성하는 요약 모델입니다.

본 Project에서는 Abstarctive Summarization을 요약 방법으로 채택한다. API 사용에 앞서 API 키를 받아주고, 사용 신청을 해야한다. 무료 버전은 한 달 최대 100건까지 가능하다. 위 링크에 들어가서 App을 새롭게 만들어주고, Secret Key를 받아온다.


1-2. API 구조

TLDRThisAPI는 Input값으로 논문의 pdf파일이 있는 주소를 받는다. 이 때, Input 값으로 한글 파일을 넣으면 인식하지 못하는 것 같다. Output은 다음과 같은 json 파일이며, API가 자동으로 해당 정보를 추출하여 출력한다.

Input

payload = {
    "url": original_url, # 주소
    "min_length": 100, # 최소 길이
    "max_length": 300, # 최대 길이
    "is_detailed": False # 한 문장으로 반환할 것인지 여부
}

Output

response.keys()
dict_keys(['summary', 'article_text', 'article_title', 'article_authors', 'article_image', 'article_pub_date', 'article_url', 'article_html', 'article_abstract'])
‘summary’ ‘article_text’ ‘article_title’ ‘article_authors’ ‘article_image’ ‘article_pub_date’ ‘article_url’ ‘article_html’ ‘article_abstract’
요약문 논문 내용 논문 제목 논문 저자 논문 이미지 논문 작성일 논문 URL 논문 HTML 논문 요약(저자가 써놓은 것)


2. PapagoAPI

2-1. API 키 발급

일련의 과정을 거쳐, ClientID와 Client Secret을 얻은 뒤, Python 환경으로 가져와준다.


1-2. API 구조

PapagoAPI는 Input으로 from language, to language, 원문을 입력해주면 그에 해당하는 번역문이 json 파일로 출력된다. 여기서는 message/result/에 있는 translatedText만 주목하면 될 것 같다.

Input

payload = {
    "source": "en",
    "target": "ko",
    "text": summary,
}

Output

{'message': {'@service': 'naverservice.nmt.proxy',
  '@type': 'response',
  '@version': '1.0.0',
  'result': {'dict': None,
   'engineType': 'UNDEF_MULTI_SENTENCE',
   'pivot': None,
   'srcLangType': 'en',
   'tarDict': None,
   'tarLangType': 'ko',
   'translatedText': '번역문'}}}


2. 함수 정의

요약부터 번역까지 일련의 과정을 담은 sum_trans를 정의하여주었다. sum_trans는 다음과 같은 Input 값을 갖는다.

def sum_trans(article_url, min_len=100, max_len=300, detail=False, trans=True, frm='en', to='ko'):
‘article_url’ ‘min_len’ ‘max_len’ ‘detail’ ‘trans’ ‘frm’ ‘to’
원문 URL 요약문 최소길이 요약문 최대길이 요약문 한줄표기 여부 번역 여부 frm lang. to lang.

3. 이슈

3-1. 제휴 문제

이 프로젝트의 주요 이용 타겟층은 전남대학교 학생으로 설정하였다. 전남대학교 학생이 주로 논문을 볼 때 사용하는 사이트는 RISS인데, 학교 ID를 사용하면 유료 논문을 무료로 볼 수 있어 많이 사용한다. 따라서 RISS에 있는 논문을 TLDRThisAPI로 summary하려고 하였으나, 요약문이 다음과 같이 이상하게 출력되었다.

 'summary': [' Not affiliated with an institution? Find more information here. State University, university.edu, The Science Institute are examples of institutions
 not affiliated with the institution.The science institute is an affiliate of the University of California State University of North Carolina. For more information,
 visit http://www.cnn.com/science-institute.org for more information about how to get involved in science education. For more info, visit the Science Institute.
 com.north Carolina-North Carolina-South Carolina.']

따라서 원문을 확인해봤는데, 제휴 문제로 인해서 논문이 제대로 읽히지 않고 있었고, 이상한 요약문이 출력되고 있었던 것이다.

  'article_text': 'Examples: State University, university.edu, The Science Institute\nNot affiliated with an institution? Find more information here.'

3-2. 원인불명 에러

제휴 문제 때문에 제대로 summary가 되지 않는 것이라면, RISS에 있는 무료 논문을 Input 값으로 넣으면 어떨까? 그래서 다른 무료 논문을 Input값으로 넣어보았다. 하지만 원인 불명의 에러가 발생하였다. 왜 발생한 것인지는 잘 모르겠다.

{'detail': "Couldn't parse the given article."}

빠른 시일내에 위 2개의 이슈를 해결하도록 노력해야겠다!!

댓글남기기