Skip to main content

An NLP python library for analyzing the german language.

Project description

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.

Project details


Download files

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

Source Distribution

wortsalat-0.0.5.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wortsalat-0.0.5-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file wortsalat-0.0.5.tar.gz.

File metadata

  • Download URL: wortsalat-0.0.5.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for wortsalat-0.0.5.tar.gz
Algorithm Hash digest
SHA256 8faf463cd0acfb18c4677a0eabc935fa4b31d2a4c77accdd1b24d5149000684b
MD5 7a9a2221c0d52080d7688699a87d097f
BLAKE2b-256 699e6128a076edf0226045f869f8b24aa4582568af917d0729118ac7fd2faab1

See more details on using hashes here.

File details

Details for the file wortsalat-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: wortsalat-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for wortsalat-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 79f81aefe59717a9d0192c6b15a654a21018f31bb9e4431d0b2cc1b0cae1ef75
MD5 4659f64f4800f79024f02003991bcce0
BLAKE2b-256 5a10d1570023d059698ac899b91c7cd9d50bb9c3709e93be5ef8a81a5d6f6a9c

See more details on using hashes here.

Supported by

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