Service Demonstrator Py


The «Service Demonstrator Py» is an implementation of the “Service Demonstrator” in the Python programming language. This is a ready-made open-source groundwork for creating future services of the Internet platform for text and speech processing www.corpus.by. Also, the service demonstrates the possible principle of the work of future services created on its basis. The service receives electronic text. The user can select an arbitrary set of options. After clicking the button, the service displays information about which text was entered and which settings were selected.

 

Access to the service via the API

To access the service «Service Demonstrator Py» via the API, you should send an AJAX-request (type: POST) to the address https://corpus.by/ServiceDemonstratorPy/api. With an input array data the following parameters are passed:

  • input — arbitrary input text.
  • checkbox1, checkbox2, checkbox3 — markers of checkbox activity; take the values «0» and «.
  • radio — active radiobuttons marker; takes values «radiobutton1», «radiobutton2», «radiobutton3», «radiobutton4», «radiobutton5».
  • selector — marker of the selected item in the drop-down menu; It takes values «option1», «option2», «option3», «option4».

Example of AJAX-request:

$.ajax({
   type: “POST”,
   url: “https://corpus.by/ServiceDemonstratorPy/api”,
   data: {
      “input”: “Уваходны тэкст.”,
      “selector”: “option1”,
      “radio”: “radiobutton2”,
      “checkbox1”: 1,
      “checkbox2”: 1,
      “checkbox3”: 1
   },
   origin: “*”,
   contentType: “application/json; charset=utf-8”,
   headers: {
      “x-api-key” : “123”
   },
   success: function(msg){ },
   error: function(err) { }
});

The server returns a JSON-array with the following parameters:

  • text — input text.
  • result — resulting text.

For example, the following reply will be formed on the above listed AJAX-request:

[
   {
      “text”: “Уваходны тэкст.”,
      “result”: Тэкст: Уваходны тэкст.\nОпцыя: опцыя #1\nКнопка-пераключальнік: кнопка-пераключальнік #2\nЧэкбокс: 1, 2, 3″
}
]

 

Links to sources

Service page: https://corpus.by/ServiceDemonstratorPy/?lang=en

Калі Вы знайшлі ў тэксце памылку правапісу, калі ласка, выдзеліце гэты тэкст і націсніце Ctrl+Enter.