tpemartin / 109-2-app101

https://tpemartin.github.io/109-2-app101/
1 stars 10 forks source link

中文排序函數 #57

Closed chao87119 closed 3 years ago

chao87119 commented 3 years ago

將原本chineseEnumerates程式,改寫為function,並可決定由大->小或由小->大

負責人 : @chao87119 @yuhong69 @jilufu

chao87119 commented 3 years ago

https://github.com/chao87119/109-2-app101/blob/main/weekly_progress/frank/sort_chineseNumbers.Rmd#L20

yuhong69 commented 3 years ago

完成: https://github.com/yuhong69/109-2-app101/blob/main/weekly_progress/yuhong/05-06-sort_chineseNumbers.Rmd

遇到的困擾:

# 討論:replace 中放迴圈?
# 以下我的想像

 str_replace_all(
    oldLevels[.x],
    c("零" = "0",
      for (.y in list(2,3,4,5,6,7,8,9,10,11)) {
          "chineseNumber1_char[.y]" = ".y-1"
          "chineseNumber2_char[.y]" = ".y-1"
        }))
chao87119 commented 3 years ago

完成: https://github.com/yuhong69/109-2-app101/blob/main/weekly_progress/yuhong/05-06-sort_chineseNumbers.Rmd

遇到的困擾:

# 討論:replace 中放迴圈?
# 以下我的想像

 str_replace_all(
    oldLevels[.x],
    c("零" = "0",
      for (.y in list(2,3,4,5,6,7,8,9,10,11)) {
          "chineseNumber1_char[.y]" = ".y-1"
          "chineseNumber2_char[.y]" = ".y-1"
        }))

在裡面直接寫for-loop可能不行, 迴圈最後不會回傳東西 也許可以寫在外面

string = c() 
for (.y in list(2,3,4,5,6,7,8,9,10,11)) {
             string[length(string)+1] <- as.character(.y-1)
             names(string)[length(string)] <- chineseNumber1_char[.y]
             string[length(string)+1] <- as.character(.y-1)
             names(string)[length(string)] <- chineseNumber2_char[.y]
  }
  map(
    1:length(origin),
    ~{str_replace_all(
            oldLevels[.x],
            c("零" = "0",
              string
            )
      )
     }
  ) -> transfer_num
tpemartin commented 3 years ago

https://github.com/chao87119/109-2-app101/blob/main/weekly_progress/frank/sort_chineseNumbers.Rmd#L20

Good job. https://github.com/chao87119/109-2-app101/blob/20266f2a2559029522cab2857bb66a1842774f2d/weekly_progress/frank/sort_chineseNumbers.Rmd#L31

jilufu commented 3 years ago

https://github.com/jilufu/109-2-app101/blob/f0b55476b10c0f905d34b46146c68f1acdaeeec9/weekly_progress/jilu/sort_chineseNumbers.Rmd#L20