Skip to main content

Dkpro cassis tools

Toolkit for managing uima cas xmi files.

Install

pip install dkpro-cassis-tools

Load cas from a zip file

from dkpro_cassis_tools import load_cas_from_zip_file
with open('cas.zip', 'rb') as f:
    cas = load_cas_from_zip_file(f)

Save cas to a zip file

from dkpro_cassis_tools import dump_cas_to_zip_file


with open('cas.zip', 'rb') as f:
    dump_cas_to_zip_file(cas, f)

Restore cas segmentation by newline

from dkpro_cassis_tools import load_cas_from_zip_file
from dkpro_cassis_tools import restore_cas_segmentation_by_newline
from dkpro_cassis_tools import dump_cas_to_zip_file


# Open the cas
with open('cas.zip', 'rb') as f:
    cas = load_cas_from_zip_file(f)

# Restore segmentation  
re_segmented_cas = restore_cas_segmentation_by_newline(cas)

# Save it
with open('re_segmented_cas.zip', 'rb') as f:
    dump_cas_to_zip_file(cas, f)    

Combine sentences from one or more cas

from dkpro_cassis_tools import load_cas_from_zip_file
from dkpro_cassis_tools import dump_cas_to_zip_file
from dkpro_cassis_tools import create_cas_from_sentences
from dkpro_cassis_tools import SENTENCE_NS


sentences = []

# Extract some sentences from cas1 
with open('cas1.zip', 'rb') as f:
    cas1 = load_cas_from_zip_file(f)
for sentence in cas1.select(SENTENCE_NS):
    if len(sentence.get_covered_text())>10:
        sentences.append((cas1, sentence))

# Extract some sentences from cas2 
with open('cas2.zip', 'rb') as f:
    cas2 = load_cas_from_zip_file(f)
for sentence in cas2.select(SENTENCE_NS):
    if len(sentence.get_covered_text())>10:
        sentences.append((cas2, sentence))

# Create the new cas
new_cas = create_cas_from_sentences(sentences) 

# Save it
with open('new_cas.zip', 'rb') as f:
    dump_cas_to_zip_file(new_cas, f)

Tokenize cas

from dkpro_cassis_tools import load_cas_from_zip_file
from dkpro_cassis_tools import tokenize_cas


wakati = MeCab.Tagger("-Owakati")

def tokenize(text: str) -> List[str]:
    return wakati.parse(text).split()

with open('data/cas_tokenize.zip', 'rb') as f:
    cas = load_cas_from_zip_file(f)
    mecab_tokenized_cas = tokenize_cas(cas, tokenize)

Metadata

Release files for dkpro-cassis-tools 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dkpro-cassis-tools 0.0.6
File Size Uploaded
dkpro_cassis_tools-0.0.6.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dkpro-cassis-tools 0.0.6
File Interpreter ABI Platform
dkpro_cassis_tools-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 13.7 kB

Release files / dkpro_cassis_tools-0.0.6.tar.gz

Download URL dkpro_cassis_tools-0.0.6.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5719bed13e723e475a4e3efb6b4d115b3ef941a276408c9d0d567998fcab89a8
BLAKE2b-256 checksum
How to use checksums
ada4eabfbf524722553a324ef652bb84b4c4fc1230e8799f9447e74ce64097ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.7.8

Release files / dkpro_cassis_tools-0.0.6-py3-none-any.whl

Download URL dkpro_cassis_tools-0.0.6-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f94326c310d0405a75e9bcf3949998f7f2fafcaee552aeb6d2d6c655b938c6c6
BLAKE2b-256 checksum
How to use checksums
30c1153ebe66ecae7cb77301111987ef891d460fbf736d3efd935f73dd9df1ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.7.8

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page