The TEPROLIN Web Service

Radu Ion (radu@racai.ro)

Introduction

The TEPROLIN Web Service (WS) was developed and is maintained in the ReTeRom project. The backend is the TEPROLIN text preprocessing platform that incorporates several NLP applications for which it provides a unified access interface as a Python 3 object.

TEPROLIN currently offers 15 text preprocessing operations for Romanian, 13 of which are described in (Ion, 2018). These are:

  1. text-normalization
  2. diacritics-restoration
  3. word-hyphenation
  4. word-stress-identification
  5. word-phonetic-transcription
  6. numeral-rewriting
  7. abbreviation-rewriting
  8. sentence-splitting
  9. tokenization
  10. pos-tagging
  11. lemmatization
  12. named-entity-recognition
    TEPROLIN new
  13. biomedical-named-entity-recognition
    TEPROLIN new
  14. chunking
  15. dependency-parsing

Configuration options

The GET queries will request for configuration information. Assuming that the WS is running on http://127.0.0.1:5000,

curl http://127.0.0.1:5000/operations

will return a JSON object with the list of 15 operations mentioned above:

TEPROLIN supported ops

A GET request with one of the TEPROLIN's operations, e.g.

curl http://127.0.0.1:5000/apps/pos-tagging

will return the JSON object with the list of the NLP apps that can perform it:

TEPROLIN apps for pos-tagging

The first NLP app is the default app to execute the operation. In the example above, pos-tagging is executed with nlp-cube-adobe.

Here is the complete list of NLP apps that TEPROLIN currently incorporates, for each operation:

  1. text-normalization
    1. tnorm-icia: an in-house developed Python 3 class that replaces old Romanian diacritics (ş and ţ) with their new variants (ș and ț), removes multiple spaces and normalizes the dash chars.
  2. diacritics-restoration
    1. diac-restore-icia: an in-house developed diacritic restoration algorithm based on word n-grams and Viterbi decoding. Developed by Tiberiu Boroș in Java, it has been ported to Python 3 and included in TEPROLIN.
  3. word-hyphenation
    1. mlpla-icia: developed in Java by Tiberiu Boroș et al. (2018).
  4. word-stress-identification
    1. mlpla-icia
  5. word-phonetic-transcription
    1. mlpla-icia
  6. numeral-rewriting
    1. mlpla-icia: developed in Java by Radu Ion et al. (2020) but integrated into mlpla-icia application.
  7. abbreviation-rewriting
    1. mlpla-icia
  8. sentence-splitting
    1. ttl-icia: provided by the TTL Perl module (Ion, 2007).
    2. nlp-cube-adobe: provided by the NLP-Cube Python 3 module (Boroș et al., 2018).
    3. udpipe-ufal: provided by the UDPipe 1 Python 3 module (Straka et al., 2016).
  9. tokenization
    1. ttl-icia
    2. nlp-cube-adobe
    3. udpipe-ufal
  10. pos-tagging
    1. ttl-icia
    2. nlp-cube-adobe
    3. udpipe-ufal
  11. lemmatization
    1. ttl-icia
    2. nlp-cube-adobe
    3. udpipe-ufal
  12. named-entity-recognition
    1. ner-icia: provided by the web service developed by Vasile Păiș, available in this NER interface.
  13. biomedical-named-entity-recognition
    1. bioner-icia: provided by a previous version of the NLP-Cube Python 3 module (Boroș et al., 2018).
  14. chunking
    1. ttl-icia
  15. dependency-parsing
    1. nlp-cube-adobe
    2. udpipe-ufal

Annotating text

In order to annotate text, you will send POST requests to the /process URL. TEPROLIN is a REST WS, meaning that there is not any saving happening between requests. If you want to use a different NLP app for a given operation, you should send the configuration option along with the text to be processed. For a full list of what operations can be executed with what NLP apps, see the previous section.

The POST request is typed with the application/x-www-form-urlencoded MIME type. The body of the request must contain only the following key=value pairs, concatenated with the & character:

text=text to be annotated here...

<operation>=<NLP app> (e.g. pos-tagging=ttl-icia)
and
exec=<operation>,<operation>,...

If exec is present, then the requested operations are performed in the proper order (the client need not bother with the order). TEPROLIN will infer the order of function calls and the modules to run such that the requested annotations are returned to the client. If exec is not present, then the full processing chain is executed (all 15 operations).

If any configuration option is present, then the specified operation(s) will be performed with the requested NLP app(s) (e.g. pos-tagging is performed with the ttl-icia NLP app).

Finally, text is the only key that is required and which contains the text to be processed.

The returned JSON object

TEPROLIN WS will respond with a JSON object containing two keys:

For example, the output for the command

curl http://127.0.0.1:5000/process -d "text=Diabetul zaharat se remarca prin valori crescute ale concentratiei glucozei in sange." -d "exec=biomedical-named-entity-recognition"

is the following:

TEPROLIN output

Getting statistics about platform usage

The TEPROLIN platform can offer statistics about the following types of events:

In order to get frequency information of the above-mentioned events, you will send GET requests to the /stats URL prefix. To obtain the full URL, you must append a statistics type (one of the tokens or requests), a time period (one of the year, month or day) and a size of the history to retrieve, an integer.

For example, to get a break-down of the number of tokens processed in the past 5 days (including the present day), you would query like this:

curl http://127.0.0.1:5000/stats/tokens/day/5

In order to get the number of requests for the current month, send this query:

curl http://127.0.0.1:5000/stats/requests/month/1

TEPROLIN will respond with a JSON object that contains the list of counts for the specified statistics type. For the first request, the response looks like this:

TEPROLIN statistics

References

Tiberiu Boroș, Ștefan Daniel Dumitrescu and Ruxandra Burtica. (2018). NLP-Cube: End-to-End Raw Text Processing With Neural Networks. In Proceedings of the CoNLL 2018 Shared Task: Multilingual Parsing from Raw Text to Universal Dependencies, Association for Computational Linguistics. pp. 171--179. October 2018

Tiberiu Boroș, Ștefan Daniel Dumitrescu and Vasile Păiș. (2018). Tools and resources for Romanian text-to-speech and speech-to-text applications. arXiv:1802.05583v1 [cs.CL]

Radu Ion. (2018). TEPROLIN: An Extensible, Online Text Preprocessing Platform for Romanian. In Proceedings of the International Conference on Linguistic Resources and Tools for Processing Romanian Language (ConsILR 2018), November 22-23, 2018, Iași, România.

Radu Ion, Badea V. G., Cioroiu G., Barbu Mititelu V., Irimia E., Mitrofan M. and Tufiș D. (2020). A Dialog Manager for Micro-Worlds. Studies in Informatics and Control, 29(4) 401--410, December 2020. ISSN: 1220-1766

Milan Straka, Jan Hajič and Jana Straková. (2016). UD-Pipe: trainable pipeline for processing CoNLL-Ufiles performing tokenization, morphological analysis, POS tagging and parsing. In Proceedings of the 10th International Conference on Language Resources and Evaluation (LREC 2016). European Language Resources Association, Portorož, Slovenia.