Cathy Wyss
9/9/2017
predictBackoff <- function(s, m, k=3) {
backoff_phrase <- cleanInputText(s)
while (TRUE) {
W <- m[m$ngram == backoff_phrase,]
if (nrow(W) > 0) # return matching words here
wordVec <- strsplit(backoff_phrase, " ")[[1]]
lwv <- length(wordVec)
if (lwv > 1) { backoff_phrase <- paste(wordVec[2:lwv], collapse=" ") }
else { backoff_phrase <- "" } } }
Phrase | imessage | my app |
---|---|---|
“i want a” | new, job, little | new, guy, relationship |
“he is” | a, the, my | a, the, not |
“how now brown” | she, is, I | said, cow |
“and a case of” | course, the, a | beer |
“oh my” | god, gosh, I | god, gosh, goodness |