Skip to main content

Wortsalat

Wortsalat is a Python library that provides various linguistic analysis tools for text data. It includes functions for tokenizing text into words and sentences, identifying words that match specific word lists or POS tags, counting the total number of words and sentences, calculating the average word length and words per sentence, and calculating various readability scores.

Installation

You can install Wortsalat from PyPI:

pip install wortsalat

Usage

Here are some examples of how to use the functions provided by Wortsalat:

Tokenize Text into Words

from wortsalat import preprocess
from wortsalat.preprocess import tokenize_words

text = "Dies ist ein Beispieltext."
words = tokenize_words(text)
print(words)

This will output: ['Dies', 'ist', 'ein', 'Beispieltext', '.']

Split Text into Sentences

from wortsalat import preprocess
from wortsalat.preprocess import split_sentences

text = "Dies ist ein Beispieltext. Hier ist eine weitere Satz."
sentences = split_sentences(text)
print(sentences)

This will output: ['Dies ist ein Beispieltext.', 'Hier ist eine weitere Satz.']

Identify Words That Match a Specific Word List

from wortsalat import identify_words
from wortsalat.identify_words import identify_words

text = "Dies ist ein Beispieltext. Hier ist eine weitere Satz."
words = identify_words('ich', text)
print(words)

This will output: []

Identify Words That Match a Specific POS Tag

from wortsalat import identify_tags
from wortsalat.identify_tags import identify_tags

text = "Dies ist ein Beispieltext. Hier ist eine weitere Satz."
words = identify_tags('ART', text)
print(words)

This will output: [('eine', 'ein', 'ART')]

Count the Total Number of Words

from wortsalat import count
from wortsalat.count import count_total_words

text = "Dies ist ein Beispieltext. Hier ist eine weitere Satz."
num_total_words = count_total_words(text)
print(num_total_words)

This will output: 9

Analyze Wortsalat

from wortsalat import analyze_wortsalat
from wortsalat.analyze_wortsalat import analyze_wortsalat

text = "Dies ist ein Beispieltext. Hier ist eine weitere Satz."
analysis = analyze_wortsalat(text)
print(analysis)

This will output:

    {
        'total number of words': 9,
        'total number of sentences': 2,
        'average word length': 4.888888888888889,
        'average words per sentence': 4.5,
        'identified pos-tags': 0,
        'identified words': 0,
        'number of adjectives': 0,
        'number of adverbs': 1,
        'number of articles': 2,
        'number of modal verbs': 0,
        'number of nouns': 2,
        'number of prepositions': 0,
        'number of pronouns': 0,
        'number of verbs': 0,
        'number of emojis': 0,
        'share of I/We': None,
        'lix': 26.72222222222222,
        'flesch-kincaid': 81.9,
        'wiener-sachtextformel': 4.9
    },
    {
        'total number of words': (
            9,
            [
                'Dies',
                'ist',
                'ein',
                'Beispieltext',
                '.',
                'Hier',
                'ist',
                'eine',
                'weitere',
                'Satz',
                '.'
            ]
        ),
        'total number of sentences': (
            2,
            ['Dies ist ein Beispieltext.', 'Hier ist eine weitere Satz.']
        ),
        'average word length': 4.888888888888889,
        'average words per sentence': 4.5,
        'identified pos-tags': 0,
        'identified words': 0,
        'adjectives': (0, 0.0, []),
        'adverbs': (1, 0.1111111111111111, [('Hier', 'hier', 'ADV')]),
        'articles': (2, 0.2222222222222222, [('ein', 'ein', 'ART'), ('eine', 'ein', 'ART')]),
        'modal verbs': (0, 0.0, []),
        'nouns': (
            2,
            0.2222222222222222,
            [('Beispieltext', 'beispiel+text', 'NN'), ('Satz', 'satz', 'NN')]
        ),
        'prepositions': (0, 0.0, 0),
        'pronouns': (0, 0.0, []),
        'verbs': (0, 0.0, []),
        'emojis': (0, 0.0, []),
        'share of I/We': None,
        'lix': 26.72222222222222,
        'flesch-kincaid': 81.9,
        'wiener-sachtextformel': 4.9
    }
)

References

Contributing - It takes a village!

If you find a bug or have a feature request, please open an issue on GitHub. If you want to contribute to the development of Wortsalat, please fork the repository, make your changes, and then open a pull request.

Additional thanks to:

License

Wortsalat is released under the Apache 2.0 License.

Metadata

Release files for wortsalat 0.0.5

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

Source distribution (sdist)

Source distribution for wortsalat 0.0.5
File Size Uploaded
wortsalat-0.0.5.tar.gz 18.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wortsalat 0.0.5
File Interpreter ABI Platform
wortsalat-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 34.6 kB

Release files / wortsalat-0.0.5.tar.gz

Download URL wortsalat-0.0.5.tar.gz
Size 18.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8faf463cd0acfb18c4677a0eabc935fa4b31d2a4c77accdd1b24d5149000684b
BLAKE2b-256 checksum
How to use checksums
699e6128a076edf0226045f869f8b24aa4582568af917d0729118ac7fd2faab1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / wortsalat-0.0.5-py3-none-any.whl

Download URL wortsalat-0.0.5-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
79f81aefe59717a9d0192c6b15a654a21018f31bb9e4431d0b2cc1b0cae1ef75
BLAKE2b-256 checksum
How to use checksums
5a10d1570023d059698ac899b91c7cd9d50bb9c3709e93be5ef8a81a5d6f6a9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.0.5 This release

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