简体   繁体   English

R的agrep函数不适用于文本匹配

[英]agrep function of R is not working for text matching

I am trying to match string using agrep function of R . 我正在尝试使用R agrep函数匹配字符串。 I do not understand, why it's not returning any value. 我不明白,为什么它不返回任何值。 I am looking a solution which will give closed match of the given text. 我正在寻找一个解决方案,将给定文本的封闭匹配。 In the given example it should show "ms sharda stone crusher prop rupa" 在给定的示例中,应显示"ms sharda stone crusher prop rupa"

I would appreciate any kind of help. 我将不胜感激。 Thanks in advance. 提前致谢。

x= as.vector(c("sharda stone crusher prop roopa","sharda stone crusher prop rupa"))
agrep("ms sharda stone crusher prop rupa devi",x,ignore.case=T,value=T,max.distance = 0.1, useBytes = FALSE)
character(0)

It is because of your max.distance parameter. 这是因为您的max.distance参数。 see ?agrep . ?agrep

for instance: 例如:

agrep("ms sharda stone crusher prop rupa devi",x,ignore.case=T,value=T,max.distance = 0.2, useBytes = FALSE)
"sharda stone crusher prop rupa"
agrep("ms sharda stone crusher prop rupa devi",x,ignore.case=T,value=T,max.distance = 0.25, useBytes = FALSE)
"sharda stone crusher prop roopa" "sharda stone crusher prop rupa" 
agrep("ms sharda stone crusher prop rupa devi",x,ignore.case=T,value=T,max.distance = 9, useBytes = FALSE)
"sharda stone crusher prop rupa"
agrep("ms sharda stone crusher prop rupa devi",x,ignore.case=T,value=T,max.distance = 10, useBytes = FALSE)
"sharda stone crusher prop roopa" "sharda stone crusher prop rupa" 

If you want only the closest match see: best match 如果只需要最接近的匹配项,请参见: 最佳匹配项

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

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