texthero

repository·master·Indexed 25 days ago

https://github.com/jbesomi/texthero

A Python package for efficient text mining and data analysis on large text-based datasets, designed to work seamlessly with Pandas Series. It provides tools for text cleaning, tokenization, TF-IDF representation, PCA dimensionality reduction, K-means clustering, and visualization (scatterplots, top words, and word clouds). The library also includes a texthero.nlp module for extracting named entities and noun chunks, and provides the Superheroes NLP Dataset for practicing NLP tasks.

Tokens
9.1K
Snippets
20
Records
92
Agent score
83%

What's inside texthero

  1. Overview of the Texthero Python package

    master

    Texthero is a Python package designed for efficient text mining and data analysis on large text-based datasets. It is built to work seamlessly with Pandas, specifically targeting the processing of text corpora (collections of documents) rather than single elements.

    Key characteristics include:

    • Pandas-centric: It is designed to work with Pandas Series. Most functions accept a Pandas Series as an argument and return a Pandas Series, allowing for easy function chaining or appending to DataFrame columns.
    • Exploratory focus: It is intended to be used as a tool for understanding underlying data before applying complex machine learning models like Transformers.
    • Efficiency: Designed to handle large quantities of text data efficiently.
    • Non-Neural Network: Texthero does not implement its own neural network solutions, instead acting as a complementary tool to libraries like PyTorch or TensorFlow.
  2. Use the texthero.nlp module for NLP tasks

    master
    The texthero.nlp module provides high-level functions for Natural Language Processing (NLP) tasks, specifically for extracting named entities and noun chunks from text. Use these functions to perform entity recognition and linguistic analysis on your datasets.
  3. Common usage patterns for Texthero

    master

    Texthero is primarily used to perform the following tasks on a text Pandas Series:

    • Cleaning: Clean a text Pandas Series.
    • Tokenization: Tokenize a text Pandas Series.
    • Representation: Represent a text Pandas Series (Note: representation functions may return a Sparse Pandas Series due to sparsity).
    • Benchmarking: Benchmark on simple models (e.g., Naive Bayes) to see if text preprocessing improvements affect model performance.
    • Data Understanding: Understand text without the need for complex models like Transformers.
    • Fact Extraction: Extract main facts from a Pandas Series.
  4. Perform stemming with hero.stem()

    master

    Use the hero.stem() method to perform stemming on text data. The method accepts a pd.Series and a stem parameter specifying the stemmer to use (e.g., "snowball").

    Best Practice: For optimal results, call do_stem after using remove_punctuation. Stemming works more effectively when punctuation has been removed from the text first.

    >>> text = "I love climbing and running."
    >>> hero.stem(pd.Series(text), stem="snowball")
       0    i love climb and running.
       dtype: object