[英]Counting letters in each index of an array in Ruby
如果您想打印每個單詞的長度,下面應該可行。
a = #[array of words]
a.each {|e| p "#{e} has #{e.length} letters"}
words = [] #array words
words.each {|w| puts "#{w} : #{w.length}"}
您可以使用 Gem "words_counted" https://github.com/abitdodgy/words_counted進行自然語言處理器的其他方式
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.