2022-01-14 17:43:27 +04:00
|
|
|
import requests
|
|
|
|
|
|
|
|
|
2022-01-14 17:07:18 +04:00
|
|
|
class Syntax:
|
2022-01-14 17:11:12 +04:00
|
|
|
|
2022-01-14 17:43:27 +04:00
|
|
|
@staticmethod
|
|
|
|
def __parsey(text, server):
|
|
|
|
print(f'Connecting to \'{server}\'...')
|
|
|
|
response = requests.post(url=f'{server}/v1/parsey-universal-full',
|
|
|
|
data=text.encode('utf-8'),
|
|
|
|
headers={
|
|
|
|
'Content-Type': 'text/plain; charset=utf-8',
|
|
|
|
'Content-Language': 'ru'
|
|
|
|
})
|
|
|
|
result = response.text
|
|
|
|
if response.status_code != requests.codes.ok:
|
|
|
|
response.raise_for_status()
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
2022-01-14 17:11:12 +04:00
|
|
|
def run(self, text: str, server: str) -> str:
|
2022-01-14 17:43:27 +04:00
|
|
|
return self.__parsey(text, server)
|