當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


R textrecipes show_tokens 顯示配方的令牌輸出

將標記作為菜譜的字符向量列表返回。此函數對於執行配方構建的診斷很有用,但不應在最終配方步驟中使用。請注意,此函數將 prep() 和 bake() 用作其所使用的配方。

用法

show_tokens(rec, var, n = 6L)

參數

rec

配方對象

var

變量名稱

n

要返回的元素數。

字符向量列表

例子

text_tibble <- tibble(text = c("This is words", "They are nice!"))

recipe(~text, data = text_tibble) %>%
  step_tokenize(text) %>%
  show_tokens(text)
#> [[1]]
#> [1] "this"  "is"    "words"
#> 
#> [[2]]
#> [1] "they" "are"  "nice"
#> 

library(modeldata)
data(tate_text)

recipe(~., data = tate_text) %>%
  step_tokenize(medium) %>%
  show_tokens(medium)
#> [[1]]
#> [1] "video"      "monitor"    "or"         "projection" "colour"    
#> [6] "and"        "sound"      "stereo"    
#> 
#> [[2]]
#> [1] "etching" "on"      "paper"  
#> 
#> [[3]]
#> [1] "etching" "on"      "paper"  
#> 
#> [[4]]
#> [1] "etching" "on"      "paper"  
#> 
#> [[5]]
#> [1] "oil"    "paint"  "on"     "canvas"
#> 
#> [[6]]
#> [1] "oil"    "paint"  "on"     "canvas"
#> 
源代碼:R/show_tokens.R

相關用法


注:本文由純淨天空篩選整理自大神的英文原創作品 Show token output of recipe。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。