在 R 中使用 tm 将包含元数据列的数据帧转换为语料库

Converting a dataframe with metadata columns to a corpus using tm in R

提问人:Rastko M. 提问时间:5/20/2023 最后编辑:GuedesBFRastko M. 更新时间:5/20/2023 访问量:35

问:

将数据框转换为语料库时出现问题

您好,我有一个有 4 列的 df(1 是文本,另外 3 是一些附加信息)。 我想将 df 转换为语料库,以便每行的文本都是一个文档,同一行不同列中的相应信息是元数据。 这些列是:

reviews  overall_grades  ambiance_grades  identifier
structure(list(reviews = c("Amazing food, I'm personally not vegan (although I'm pro vegan) but this is the second time I go to Alter and it does feel like a treat every time! Highly recommend, vegan or not, it's amazing", "One of the best vegan menus in London. Pizza dough is to die for!", "The food was incredible with a variety of flavours! I'll definitely be coming back when I'm in town.", "Fantastic! Will come again and recommend to friends.", "Hard to find the door to the building, hard to find the restaurant. They only mix cocktails on their menu, no classics. Food delicious, service great, a little pricey."), overall_grades = c("5", "5", "5", "5", "3"), ambiance_grades = c("5", "5", "5", "5", "3"), identifier = c("Alter", "Alter", "Alter", "Alter", "Alter")), row.names = c(NA, 5L), class = "data.frame")
R DataFrame 文本挖掘 TM 语料库

评论


答: 暂无答案