【问题标题】:Extract verbs from sentence in R?从R中的句子中提取动词?
【发布时间】:2019-06-19 10:59:19
【问题描述】:

请注意我知道Extracting Nouns and Verbs from Text 它对我不起作用,因为他们使用的功能在openNLP 包中不存在。

这是我的字符串列:

tibble(recipe_name = c("Easter Leftover Sandwich", "Pasta with Pesto Cream Sauce", 
"Herb Roasted Pork Tenderloin with Preserves", "Chicken Florentine Pasta", 
"Perfect Iced Coffee", "Easy Green Chile Enchiladas", "Krispy Easter Eggs", 
"Patty Melts", "Yum. Doughnuts!", "Buttery Lemon Parsley Noodles", 
"Roast Chicken", "Baked French Toast", "Yummy Slice-and-Bake Cookies", 
"Yummy Grilled Zucchini", "Chocolate Covered S’mores", "T-Bone Steaks with Hotel Butter", 
"Mango Margaritas!", "Tuscan Bean Soup with Shrimp", "Hoppin’ John", 
"Turkey Bagel Burger"))

我想进行分析,找出每个名称中的所有动词/名词等。

如何在 R 中做到这一点? 我检查了qdaptm 包,但没有找到可以提取它的函数。

请告知如何执行此操作。

【问题讨论】:

    标签: r nlp


    【解决方案1】:

    您可以使用 udpipe 库中的 udpipe_annotate 函数来获取它:

    library(udpipe)
    ud_model <- udpipe_download_model(language = "english")
    ud_model <- udpipe_load_model(ud_model$file_model)
    system.time(
      x <- udpipe_annotate(ud_model, x = df$recipe_name, doc_id = df$id)
    )
    x <- as.data.frame(x)
    abc <- c("NN","VB")
    stats <- dplyr::filter(x,grepl(pattern = paste(abc, collapse = "|"), x = xpos, ignore.case = T))
    

    您还可以使用this 列表中的单词类型列表。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多