首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何用R码找出句子中的连词

如何用R码找出句子中的连词
EN

Stack Overflow用户
提问于 2015-06-17 11:36:06
回答 2查看 481关注 0票数 4

如何用R码找出句子中的连词。

例如:

下面提到了一个句子,它是以下内容的输出

代码语言:javascript
复制
sentence <- text[grep("Guarantee of",text)]

请提交13,863.00卢比/-(13,000,863卢比)的履约保证

现在我需要得到"Rs.13,863.00/-"的连续词“的保证”

-Thanks

EN

回答 2

Stack Overflow用户

发布于 2015-06-17 11:40:12

代码语言:javascript
复制
sentence <- 'You are requested to submit the Performance Guarantee of Rs.13,863.00/-( Rupees thirteen thousand and eight sixty three)';
sub('.*Guarantee\\s+of\\s+([a-zA-Z0-9,._/-]+).*','\\1',sentence);
## [1] "Rs.13,863.00/-"
票数 1
EN

Stack Overflow用户

发布于 2015-06-17 11:42:05

试一试

代码语言:javascript
复制
gsub('.*Guarantee of\\s*|\\(.*', '', str1)
[1] "Rs.13,863.00/-"

代码语言:javascript
复制
library(stringr)
str_extract(str1, '(?:Rs.)[^(]+')
#[1] "Rs.13,863.00/-"

数据

代码语言:javascript
复制
  str1 <- "You are requested to submit the Performance Guarantee of Rs.13,863.00/-( Rupees thirteen thousand and eight sixty three)"
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30890432

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档