【发布时间】:2019-02-24 23:32:47
【问题描述】:
例句
sentence <-'When Sebastian Thrun started at Google in 2007, few people outside of the company took him seriously.'
这是从 spacyr 包中提取的实体:
spacy_extract_entity(sentence)
我想为 ent_type 分配我自己的颜色的查找列表
ent_type <- c('PERSON', 'ORG', 'DATE')
color <- c('#a3de2a', '#45c4f9', '#2ebaad')
如何返回 ent_type 和颜色值,并在句子中使用 paste0() 函数替换为 str_replace_all 中的 html 标记。
示例:
paste0('<span style=\"background-color:', color, '\ ">',text,' #<span style=\"font-size:8px;font-weight:bold;background-color:white;">',ent_type,'</span></span>')
【问题讨论】:
-
将示例输出显示为代码而不是图像。