Skip to main content

Lychee Language Core: Optimized Slang Replacement and NLP Toolkit.

Project description

Lychee Language Core (him-lychee) Version 0.2.0 - Developed by Himpadma "Him"

Lychee is a lightweight, highly optimized Python package designed to quickly process user-generated text. It provides robust, single-pass slang replacement and a powerful suite of text cleaning tools necessary for Natural Language Processing (NLP) tasks like Sentiment Analysis.

Installation pip install him-lychee

Post-Installation Setup (Required for Full NLP Features) To use the advanced features (Stopwords, Stemming, Lemmatization, SpaCy), you must download the required models once:

python -m nltk.downloader stopwords punkt wordnet python -m textblob.download_corpora python -m spacy download en_core_web_sm

Lychee Core Usage (SlangDictionary Class) The core SlangDictionary class provides robust, optimized slang replacement.

Method

Description

Example Usage

replace_slang_in_text(text)

Crucial for Data Cleaning. Replaces all recognized slang terms in a single string with their full meanings. Highly optimized using a single regex pass.

slang_core.replace_slang_in_text(text)

get_meaning(slang_term)

Finds the meaning of a given slang term (case-insensitive).

slang_core.get_meaning('BRB')

reverse_lookup(meaning)

Finds all slang terms that map to a specific meaning.

slang_core.reverse_lookup('Laugh out loud')

Pandas Example (Recommended Usage) import pandas as pd import lychee

slang_core = lychee.SlangDictionary() df = pd.DataFrame({'review': ['OMG, that pic is GOAT!', 'IDK why BRB took so long.']})

Apply the function across the entire DataFrame column for high speed

df['cleaned_review'] = df['review'].apply(slang_core.replace_slang_in_text)

NLP Cleaning Pipeline (TextCleaner Class) The TextCleaner class provides functions to prepare text for machine learning models.

cleaner = lychee.TextCleaner() text = "The
GOAT said: https://example.com/ LOL! 😃"

Function

Description

Example Usage

remove_html_tags(text)

Strips HTML markup from the text.

cleaner.remove_html_tags(text)

remove_urls(text)

Removes all web URLs (http, https, www).

cleaner.remove_urls(text)

remove_punctuation(text)

Removes standard punctuation marks.

cleaner.remove_punctuation(text)

clean_emojis(text, mode='replace')

Replaces emojis with text codes (e.g., 😃 -> :smiling_face:), or removes them if mode='remove'.

cleaner.clean_emojis(text, 'replace')

remove_stopwords(text)

Removes common stop words (e.g., 'a', 'the', 'is').

cleaner.remove_stopwords(text)

spelling_correction(text)

Corrects common misspellings (using TextBlob, can be slow).

cleaner.spelling_correction(text)

stem_words(text)

Reduces words to their root form (e.g., 'running' -> 'run').

cleaner.stem_words(text)

lemmatize_text(text)

Reduces words to their dictionary form (e.g., 'better' -> 'good').

cleaner.lemmatize_text(text)

tokenize(text, library='nltk')

Splits text into word tokens using either NLTK or SpaCy.

cleaner.tokenize(text, 'spacy')

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

him_lychee-0.2.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

him_lychee-0.2.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file him_lychee-0.2.0.tar.gz.

File metadata

  • Download URL: him_lychee-0.2.0.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for him_lychee-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e1b0a8951402925ec9a22f0c2bd54d3b30c95be8b5aff319c1216a652c9a6271
MD5 d887423279ab1519f4f1c55a119908f9
BLAKE2b-256 542baa4861e4bff156fe29779179c1f42ec0e227ba6284bb930330521b6f1a89

See more details on using hashes here.

File details

Details for the file him_lychee-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: him_lychee-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for him_lychee-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 14a68f835a8c702865b0c1512ef655b493c8c746359802195be4a5be4e946d81
MD5 d6300e01e17ec1cac399352da02bbed4
BLAKE2b-256 32618f35137bfa3138456654aff707468869de6274c5df6c9a37616152dc9104

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