Kind_markov_chains
I’ve been fortunate to work with great mentors and professors who are willing to act as references for me. But who needs human compassion, when you have markov chains you can train to be nice to you.
This is not exactly a great showcase of my technical ability. I think it took about 5 minutes to rip a few review datasets off kaggle, and slapped them into someone elses MCs . But I’m a big fan of the results.
Review datasets from here and here
wine_df <- read.csv("wine-reviews\\winemag-data_first150k.csv", stringsAsFactors = FALSE, encoding = "UTF-8")
Hotel_df <- read.csv("Hotel_Reviews.csv", stringsAsFactors = FALSE, encoding = "UTF-8") %>% select(Positive_Review, Average_Score)
First the training material for winebot
great_wine_df <- wine_df %>%
filter(points > 95, price > 100)
#fancy expensive wines only, please.
positive_wine_text <- paste(great_wine_df$description)
winefile <- file("positive_wine_text.txt")
writeLines(positive_wine_text, winefile)
great_hotel_df <- Hotel_df %>% filter(Average_Score >= 9)
great_hotel_df <- great_hotel_df[sample(nrow(great_hotel_df), size = 500), ]
positive_hotel_text <- paste(great_hotel_df$Positive_Review, collapse = ".")
#little bit big, so I sample 500 at random, and add in punctuation.
hotelfile <- file("positive_hotel_text.txt")
writeLines(positive_hotel_text, hotelfile)
the smidge of python I used for markovify
import markovify
import sys
# Get raw text as string.
with open(sys.argv[1]) as f:
text = f.read()
# Build the model.
text_model = markovify.Text(text)
# Print five randomly-generated sentences
for i in range(5):
print(text_model.make_sentence())
# Print three randomly-generated sentences of no more than 100 characters
for i in range(3):
print(text_model.make_short_sentence(100))
Some of my acolades
winebot
The latest release is their best ever, toasty and superbly mature.
dramatic, compulsively good is the elegance that is developing.
This new vintage is an outstanding achievement.
hotelbot
[Tom is] warm, caring and not dirty.
[Tom is] amazing and made me feel at home
[Tom is] a superb fantastic modern beautiful clean amazing [person]