This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |