Skip to content

Instantly share code, notes, and snippets.

View caitlinhudon's full-sized avatar

Caitlin Hudon caitlinhudon

View GitHub Profile
@caitlinhudon
caitlinhudon / text_analysis.py
Created April 17, 2024 01:52
text_analysis.py
import pandas as pd
import matplotlib.pyplot as plt
from wordcloud import WordCloud
from sklearn.feature_extraction.text import CountVectorizer
from nltk.stem.snowball import SnowballStemmer
from nltk.tokenize import word_tokenize
from nltk.util import ngrams
from collections import Counter
def generate_ngrams_and_plots(text_input):
@caitlinhudon
caitlinhudon / text_analysis.R
Created April 17, 2024 01:51
text_analysis.R
library(tidytext)
library(dplyr)
library(tokenizers)
library(ggplot2)
library(wordcloud)
# Function to stem generic text input, generate n-grams, and plot results
generate_ngrams_and_plots <- function(text_input) {
# Convert text input to a tibble
text_input_df <- tibble(text = text_input)