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.
Release files for sos-ruta 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sos-ruta-0.1.tar.gz | 6.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sos_ruta-0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.3 kB
Release files / sos-ruta-0.1.tar.gz
| Download URL | sos-ruta-0.1.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8e80af30957597c0dee13a6abd1b85966fbe617d5e1e6846f63f97c08e8ea3b
|
|
BLAKE2b-256 checksum How to use checksums |
1e99b377f1483ac14798bbedb48c6b1716d6182451142bcbeea71e7d5ab1d619
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / sos_ruta-0.1-py3-none-any.whl
| Download URL | sos_ruta-0.1-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
73d0586a0a8ed4162bb875d490fc294944bc87bd0db5272afdf9d7d573efd3f8
|
|
BLAKE2b-256 checksum How to use checksums |
e8aaa28bfd0a351fa90fb0a4aeb2b9abfa0b79ccee02348452f3df0b45534605
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|