Skip to main content

SoS Notebook extension for the language Apache UIMA Ruta

Project description

SoS language module for Apache UIMA Ruta

SoS Notebook is a Jupyter kernel that allows the use of multiple kernels in one Jupyter notebook. This module provides a language module for the IRuta kernel that is based on the Apache UIMA Ruta programming language.

PIP installation

To install this repository from PyPI, use pip install sos-ruta. To install this repository from source, clone it and run pip install . in this directory.

Usage

Transfering String variables from Python to Ruta

Using the %expand magic, one can transfer String variables from Ruta to Python Cells in the same notebook. Please see the example below.

Python Cell

documentText = '"Patient has fevers, but no chills."'
problem_list = '"fevers|chills|nausea"'
newTypeName  = "Diagnosis"

Ruta Cell

%expand
%documentText {documentText}
DECLARE {newTypeName};
{problem_list} -> {newTypeName};
COLOR({newTypeName},"green");

is automatically expanded to

%documentText "Patient has fevers, but no chills."
DECLARE Diagnosis;
"fevers|chills|nausea" -> Diagnosis;
COLOR(Diagnosis,"green");

This annotates "fevers" and "chills" as annotations of type "Diagnosis".

Transfering an Apache UIMA Cas object from Python to Ruta and back

A Cas object holds information about the document text and all annotations together with a TypeSystem. They can be exchanged between UIMA Ruta and Python using the Python library dkpro-cassis and this sos-ruta package.

Sending a Cas from Python to Ruta

(In a Python cell) Load a UIMA Cas with dkpro-cassis.

import cassis
with open('MyTypeSystem.xml', 'rb') as f:
    typesystem = cassis.load_typesystem(f)   

with open("MyCasExample.xmi", "rb") as f:
    cas1 = cassis.load_cas_from_xmi(f, typesystem=typesystem)

Transfer it to UIMA Cas using the %get cas1 magic command in a Ruta Cell. This automatically loads the content of the variable cas1 together with its TypeSystem into the current Cas in Ruta.

(In a Ruta cell) Execute the following magic that is provided by sos-ruta to pass a Cas from Python to Ruta.

%get cas1`

One can for instance inspect the results with a basic AnnotationViewer using the magic %displayMode DYNAMIC_HTML.

Sending a Cas from Ruta to Python

If required, the Cas object can be passed back to Python using %put cas_output which assigns the content of the current Cas in Uima Ruta to a variable named cas_output in Python.

(In a Ruta cell) Execute the following magic that is provided by sos-ruta to pass the Cas from Ruta to Python.

%put cas_output

Tests

The tests in this repository use Selenium and Google Chrome to simulate a Jupyter Notebook. Please read more about sos-notebook tests here: https://vatlab.github.io/sos-docs/doc/user_guide/language_module.html#Testing.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sos-ruta-0.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

sos_ruta-0.1-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file sos-ruta-0.1.tar.gz.

File metadata

  • Download URL: sos-ruta-0.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for sos-ruta-0.1.tar.gz
Algorithm Hash digest
SHA256 e8e80af30957597c0dee13a6abd1b85966fbe617d5e1e6846f63f97c08e8ea3b
MD5 1b389e463490525fa62903b82824e2d5
BLAKE2b-256 1e99b377f1483ac14798bbedb48c6b1716d6182451142bcbeea71e7d5ab1d619

See more details on using hashes here.

File details

Details for the file sos_ruta-0.1-py3-none-any.whl.

File metadata

  • Download URL: sos_ruta-0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for sos_ruta-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 73d0586a0a8ed4162bb875d490fc294944bc87bd0db5272afdf9d7d573efd3f8
MD5 ccee85e4844d68ec7a45081b488955ed
BLAKE2b-256 e8aaa28bfd0a351fa90fb0a4aeb2b9abfa0b79ccee02348452f3df0b45534605

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page