-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.R
29 lines (22 loc) · 792 Bytes
/
run.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
source("libs_constants.R")
source("functions.R")
source("utils.R")
# Connect to the DB
message("Connecting to DB!")
pg <- httr::parse_url(Sys.getenv("DATABASE_URL"))
dbConnect(RPostgres::Postgres(),
dbname = trimws(pg$path),
host = pg$hostname,
port = pg$port,
user = pg$username,
password = pg$password,
sslmode = "require"
) -> DB_CON
# hook it up to dbplyr
DB <- src_dbi(DB_CON)
# Retrain model - capturing any new feedback tweets since the last time the model was retrained. Also updates the dictionary
model.and.dict <- retrainModel()
# Get latest trump tweet
last.tweet <- getLastTweet()
# Generate model scores for new trump tweets (if any)
predictions <- predictTweets(last.tweet, model.and.dict, post.tweets = TRUE)