better pattern detection

This commit is contained in:
2015-01-12 14:59:51 +01:00
parent 714845a8f0
commit fd4ea4a47e
2 changed files with 40 additions and 1 deletions
+19 -1
View File
@@ -25,7 +25,7 @@ for(d in 1:nrow(issues)) {
for(t in 1:nrow(tweets_curday)){
# Select tweet's text, make it lowercase and remove hashtag indicators (#)
curtext <- tolower(as.character(tweets_curday$text[t]))
curtext <- as.character(tweets_curday$text[t])
curtext <- str_replace_all(curtext, "#", "")
for(i in 1:length(issuelist)) {
@@ -35,6 +35,24 @@ for(d in 1:nrow(issues)) {
tags_found <- str_detect(curtext, sprintf("%s", curtags))
tags_found <- any(tags_found)
######
# Test all tags in ONE issue
for(t in 1:length(curtags)) {
curtag <- curtags[t]
curchars <- nchar(curtag, type = "chars")
tags_found <- smartPatternMatch(curtext, curtag, curchars)
if(tags_found == 1) {
cat("Text contains at least the tag:", curtag, "\n")
break
}
}
######
if(tags_found) {
#cat("Positive in", curissue,"from",as.character(drange[d]),"\n")
issues[d,curissue] <- issues[d,curissue] + 1