dmis-lab / BERN2

BERN2: an advanced neural biomedical namedentity recognition and normalization tool
http://bern2.korea.ac.kr
BSD 2-Clause "Simplified" License
175 stars 42 forks source link

BERN2 RestfulAPI can't query plain text #43

Closed khoakoxoan closed 1 year ago

khoakoxoan commented 1 year ago

Hello! I was trying to use BERN2 Restful API with some examples, but when I query this sentence the API return a JSONDecodeError: : Expecting value: line 1 column 1 (char 0) :

import requests
def query_plain(text, url="http://bern2.korea.ac.kr/plain"):
    return requests.post(url, json={'text': text}).json()
if __name__ == "__main__":
    text = 'Growth of Escherichia coli in the presence of nitrate or nitrite G:C base pair is also the strongest determinant in This leading to a 45% decrease in expression (Lagrange et al., 1998).'
    print(query_plain(text))

And when I try to see the reponse content a = requests.post('http://bern2.korea.ac.kr/plain', json={'text': text}) a.content.decode('utf-8')

return this instead of a JSON like other sentences:

<html>\r\n<head>\r\n<title>Block Page-192</title>\r\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\r\n</head>\r\n<body bgcolor="#FFFFFF" text="#000000">\r\n<table width="600" border="0" cellspacing="0" cellpadding="0" align="center">\r\n <tr>\r\n <td></td>\r\n </tr>\r\n</table>\r\n<table width="600" border="0" cellspacing="1" cellpadding="2" align="center" bgcolor="#CCCCCC">\r\n <tr>\r\n <td bgcolor="A0B8C8" height="20">\r\n <div align="left"><font size="2"><b> <font color="#FFFFFF">페이지 차단(PAGE BLOCK)</font></b></font></div>\r\n </td>\r\n </tr>\r\n <tr>\r\n <td bgcolor="#FFFFFF">\r\n <table width="95%" border="0" cellspacing="0" cellpadding="0오전 8:55 2007-08-27" align="center">\r\n <tr>\r\n <td><font size="2" color="#336699"><br>\r\n <font color="#FF0000"><b>접속차단 - 웹 보안 정책 위반<br>(Blocked - Violation of Web Security Policy)</b></font><font color="#333366"><br>\r\n <br>\r\n <br><p>\r\n 죄송합니다. 요청하신 페이지는 보안정책에 위반되었습니다. </font>\r\n <p><font size="2" color="#333366">허용되지 않은 특수 문자입력이나 업로드 파일확장자가 적합하지 않을 수 있습니다.</font></p>\r\n <p><font size="2" color="#333366">URL이 정확하다면 잠시후에 다시 연결을 시도해 보시기 바라며</font></p>\r\n <p><font size="2" color="#333366">계속 같은 현상이 발생한다면 고려대학교 디지털정보처</font></p>\r\n <p><font size="2" color="#333366">(02-3290-4191/4196, ifsea@korea.ac.kr, yerlsim@korea.ac.kr)로 연락을 주시기 바랍니다.</font></p>\r\n <p><font size="2" color="#333366"><b>\r\n <script language="JavaScript">\r\n var today = new Date();\r\n document.write("차단시각 : " + today.toLocaleString());\r\n </script></b></font></p>\r\n <p><font size="2" color="#333366"><b>접속IP : 113.173.37.170</b></font></p>\r\n <p><font size="2" color="#333366"><b>차단경로 : http://bern2.korea.ac.kr/plain </b></font></p>\r\n <p><font size="2" color="#333366">연락 주실때 차단된 시각, 접속IP,와 접속한 URL창의 내용을 함께 알려주시기 바랍니다.</font></p>\r\n <p><font size="2" color="#333366"><a href="javascript:history.go(-1);"><b>이전 페이지로 이동</b></a>도 가능합니다.</font></p>\r\n </td>\r\n </tr>\r\n </table>\r\n <br>\r\n </td>\r\n </tr>\r\n</table>\r\n<p>\r\n<div align="center"><font face="Arial, Helvetica, sans-serif" size="2" color="#333333"><b>고려대학교 디지털정보처 정보인프라부 ☎ 02-3290-4191, 4196, security@korea.ac.kr</b></font></div>\r\n</body>\r\n</html> Any idea how I can fix this? Thanks in advance and thanks for building such a nice tool

mjeensung commented 1 year ago

Hi @khoakoxoan

I apologize for the inconvenience, but I was unable to reproduce the issue when testing on the API or Demo. It is possible that certain special characters in your input string are not allowed by the BERN2 server for security reasons. However, when I copied and pasted your input string, it worked correctly from my side.

Could you please check which character is causing the problem?

image

image

khoakoxoan commented 1 year ago

Thank you for your reply