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
Sub Insert_Pics() | |
Dim strTemp As String | |
Dim strPath As String | |
Dim strFileSpec As String | |
Dim oSld As Slide | |
Dim oPic As Shape | |
' logos will be inserted in the alpha sequence; I renamed files with leading numbers (001, 002) |
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
Sub Add_Text_Excel_loop() | |
' Reference: http://www.vbaexpress.com/forum/showthread.php?43287-Loop-to-Copy-Text-From-Excel-to-Powerpoint-Text-Boxes | |
sn = GetObject("C:\Users\Excelfile.xlsm").sheets(1).Range("O1:S150") 'reference to an Excel file | |
ActiveWindow.View.GotoSlide Index:=1 ' go to slide number one | |
' here is the manual input to 50 slides | |
For j = 1 To 50 | |
' update number in top left | |
ActivePresentation.Slides(j).Shapes("Shape 1").TextFrame.TextRange.Text = j | |
' update title - in my case, my excel file jumps from 3 to 3 lines, so that's why j times 3 (j *3) |
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
Sub Slide_Creation() | |
' this sub duplicates the standard slide | |
Dim myPres As Presentation | |
Dim mySlide As SlideRange | |
Dim count As Long | |
For j = 1 To 49 ' this will create in total 50 slides (one original plus 49 duplicates) | |
Set myPres = ActivePresentation | |
' Duplicate the slide at index 'count'. |
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
# Function to expand contractions and convert numbers to "num" ----- | |
# Loop only used to control memory/progress | |
expand_contraction = function (text) { | |
text %<>% str_replace_all(pattern = "[`''']",replacement = "'" ) | |
text %<>% tolower() | |
text %<>% str_replace_all(pattern = "\\b\\w*\\d,*\\.*\\w*,*\\.*\\b", replacement = "num") # the real regex is \b\w*\d,*\.*\w*,*\.*\b | |
text %<>% str_replace_all(pattern = "\\b(num)\\W*\\S*(num)\\b", replacement = "num") | |
{for (i in (seq_along(contrac_repl))) | |
text %<>% str_replace_all(pattern = tolower(names(contrac_repl))[i] ,replacement = tolower(contrac_repl[i])) | |
} |
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
# load RDS and libraries | |
load("20170724.RData") | |
# this is function to predict only | |
library("tidyverse") | |
library("stringr") | |
library("textclean") | |
library("lexicon") | |
library("magrittr") |
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
if (lengthtext >4) {fivechance = fivegrams %>% filter(third_next_word==word_search_last, sec_next_word == word_search_last_minus_one, next_word == word_search_last_minus_two, word == word_search_last_minus_three) %>% top_n(5,wt = fiveprop) %>% mutate(chance = fiveprop*0.4^(backoff_index-4), origin="fivegrams") %>% ungroup() %>% select(selection = fourth_next_word, chance, origin)} | |
if (lengthtext >3) {fourchance = fourgrams %>% filter(sec_next_word==word_search_last, next_word==word_search_last_minus_one, word==word_search_last_minus_two) %>% top_n(5, wt=fourprop) %>% mutate(chance = fourprop*0.4^(backoff_index-3), origin = "fourgrams") %>% ungroup() %>% select(selection = third_next_word, chance, origin)} | |
if (lengthtext >2) {threechance = trigrams %>% filter(next_word==word_search_last,word==word_search_last_minus_one) %>% top_n(5, wt=triprop) %>% mutate(chance = triprop*0.4^(backoff_index-2), origin = "trigrams") %>% ungroup() %>% select(selection = sec_next_word, chance, origin)} | |
if (length |
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
# this script validates the prediction using a test dataset | |
# Library Load ------------------------------------------------------------ | |
listpackages = c('tm', 'tidyverse','ggplot2','scales','DT', 'tidyr', 'igraph','magrittr','gridExtra','readr','stringi','stringr','textclean','reshape2', 'tidytext','data.table') | |
loaded = suppressMessages(suppressWarnings( | |
sapply(listpackages, function (x) library(x,character.only = T)) | |
)) | |
rm(list = c('listpackages','loaded')) |
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
# this script validates the prediction using a test dataset | |
# Library Load ------------------------------------------------------------ | |
listpackages = c('tm', 'tidyverse','ggplot2','scales','DT', 'tidyr', 'igraph','magrittr','gridExtra','readr','stringi','stringr','textclean','reshape2', 'tidytext','data.table') | |
loaded = suppressMessages(suppressWarnings( | |
sapply(listpackages, function (x) library(x,character.only = T)) | |
)) | |
rm(list = c('listpackages','loaded')) |