如何从文字

时间:2017-09-22 07:31:38

标签: r api for-loop while-loop geocoding

以下是我的函数示例中的getscodes

df= read.csv("secondary.csv",header = TRUE)

1 个答案:

答案 0 :(得分:0)

SELECT dishes.title,
       dishes.name,
       dishes.id,
       countries.locale
FROM countries 
    JOIN companies ON companies.`country_id` = countries.`id`
    JOIN company_dish  ON company_dish.`company_id` = companies.`id`
    JOIN dishes  ON company_dish.`dish_id` = dishes.`id`
GROUP BY dishes.`title`, countries.locale
ORDER BY ??? count_dishes_in_each_locale ?? DESC

我建议制作所有可能的N-x字符串,其中N是字符串的长度,x是可变长度

S <- "s / O sk hungu 101 / 90 MODEL HOUSE TALAB GAGNI SHUKUL LUCKNOW UTTAR PRADESH LUCKNOW UTTAR PRADESH 226001"

您可以遍历此列表以检查有效的地理编码。我必须提供伪代码,因为我不确定如何检查字符串是否是有效的地理编码。

allchr <- unlist(strsplit(S, ""))
listsubstr <- sapply(1:length(allchr), function(I) paste0(allchr[I:length(allchr)], collapse=""))

  # [1] "s / O sk hungu 101 / 90 MODEL HOUSE TALAB GAGNI SHUKUL LUCKNOW UTTAR PRADESH LUCKNOW UTTAR PRADESH 226001"
  # [2] " / O sk hungu 101 / 90 MODEL HOUSE TALAB GAGNI SHUKUL LUCKNOW UTTAR PRADESH LUCKNOW UTTAR PRADESH 226001" 
  # [3] "/ O sk hungu 101 / 90 MODEL HOUSE TALAB GAGNI SHUKUL LUCKNOW UTTAR PRADESH LUCKNOW UTTAR PRADESH 226001"  
  # [4] " O sk hungu 101 / 90 MODEL HOUSE TALAB GAGNI SHUKUL LUCKNOW UTTAR PRADESH LUCKNOW UTTAR PRADESH 226001" 

你也可以通过递归来做到这一点。

sapply(listsubstr, function(I) is.geocode(I))     # contains pseudocode