简体   繁体   English

如何使用R代码找出句子中的连续单词

[英]How to find out the consecutive word in a sentence using R code

How to find out the consecutive word in a sentence using R code. 如何使用R代码找出句子中的连续单词。

For Example: 例如:

There is a sentence like mentioned below which is the output of the following 有如下所述的句子,它是以下的输出

sentence <- text[grep("Guarantee of",text)]

"You are requested to submit the Performance Guarantee of Rs.13,863.00/-( Rupees thirteen thousand and eight sixty three)" “你被要求提交13,863.00卢比的性能保证 - (卢比一万三千八百六十三)”

Now I need to get the consecutive word of "Guarantee of" which is "Rs.13,863.00/-" 现在我需要得到“保证”的连续字,即“Rs.13,863.00 / - ”

-Thanks -谢谢

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/-"

Try 尝试

gsub('.*Guarantee of\\s*|\\(.*', '', str1)
[1] "Rs.13,863.00/-"

Or 要么

library(stringr)
str_extract(str1, '(?:Rs.)[^(]+')
#[1] "Rs.13,863.00/-"

data 数据

  str1 <- "You are requested to submit the Performance Guarantee of Rs.13,863.00/-( Rupees thirteen thousand and eight sixty three)"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM