私はthis nice solutionを、your_sentenceの入力としてデータフレームを使ってテストしようとしています。データフレームからのテキスト引数
remove_words <- function(sentence, badword="blame"){
tagged.text <- treetag(file=sentence, format="obj", treetagger="manual", lang="en",
TT.options=list(path=":C\\Treetagger", preset="en"))
# Check for bad words AND verb:
cond1 <- ([email protected]$token == badword)
cond2 <- (substring([email protected]$tag, 0, 1) == "V")
redflag <- which(cond1 & cond2)
# If no such case, return sentence as is. If so, then remove that word:
if(length(redflag) == 0) return(sentence)
else{
splitsent <- strsplit(sentence, " ")[[1]]
splitsent <- splitsent[-redflag]
return(paste0(splitsent, collapse=" "))
}
}
lapply(your_sentences, remove_words)
データフレームには、1列と351行があります。 your_sentencesでlapplyでは(私はコールせずに列をデータフレームを使用する場合、同じエラーがある)私は自分のデータフレームのためのコールと列名を使用して、私はこのエラーが表示されます。
> dfnew <- lapply(df$text, remove_words)
Error in writeLines(text, con = conn.tempfile) : invalid 'text' argument
は私が解決するために何ができますエラー?
例データ:
df = data.frame(text = c('I blame myself for what happened', 'For what happened the blame is yours', 'I will blame you if my friend removes'))
を使用すると、エラーが何かがあることを示していますのでことを変更することができます。引数として
stringsAsFactors = FALSE
を使用することで問題を解決しますあなたの一時ファイルに間違っているのは、あなたのパスに誤字があるかもしれないということです。 'path =":C \\ Treetagger "'。コロンの前にCを続けてはいけません。 –@ManuelBickelありがとうございます。私はパス= "C:\\ Treetagger"を修正しましたが、残念ながらエラーが存在します – PitterJe