-
Notifications
You must be signed in to change notification settings - Fork 8
議事録(118)
yowasou edited this page Aug 13, 2023
·
2 revisions
-
https://ja.wikipedia.org/wiki/%E5%9B%9A%E4%BA%BA%E3%81%AE%E3%82%B8%E3%83%AC%E3%83%B3%E3%83%9E
-
いずれプログラム投稿&戦わせるサイトを作りたい...
- transposeが鍵
puts %w[パトカー タクシー].map(&:chars).transpose.tap{|a| p a}.inject('') { |buf, (a, b)| buf + a + b }
puts %w[パトカー タクシー].map(&:chars).transpose.join
# https://nlp100.github.io/ja/ch01.html
ar1 = 'パトカー'.chars
ar2 = 'タクシー'.chars
ret = []
ar1.each_with_index do |v, i|
ret << v
ret << ar2[i]
end
p ret.join
a = "パトカー"
b = "タクシー"
s = b.split("")
i = 0
j = ""
a.split("").each { |c|
j = j + c + s[i]
i = i + 1
}
p j
a = "パトカー"
b = "タクシー"
p a.chars.zip(b.chars).flatten.join
- joinの懐が深い
[1,2,3,[4,5]].join
=> "12345"
-
みんなmap使ってるのが上達した感がある
-
正規表現がつかえるとよりよい
-
カンマ(,)とドット(.)があるから注意
a = "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics."
p a.split.map(&:length)
ar = "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.".gsub(',', '').split(' ').map do |v|
v.size
end
p ar
p <<~EOS.split(/[\s,.]+/).map(&:length)
Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.
EOS
a = "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics."
b = a.gsub(",","").gsub(".","").split(" ")
b = b.map { |c| c.length }
p b
p 'Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.'.split.map(&:size)
a = "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics."
p a.delete(",.").split.map(&:length)
p <<~EOS.scan(/\w+/).map(&:length)
Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.
EOS
p <<~EOS.scan(/[[:alpha:]]+/).map(&:length)
Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.
EOS
a = "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics."
p a.delete("^A-z ").split.map(&:length)
a="Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics."
p a.tr(".","").split(" ").map{|x|x.size}
-
英語で言うところの「水平リーベ」の語呂合わせ
-
https://en.wikipedia.org/wiki/List_of_chemistry_mnemonics#Periodic_table
-
こんなハッシュを作る
hash = { "H" => 1, "He" => 2, "Li" => 3, ...}
- 二次元配列をto_hすると配列になります。zipしてからでも。
single_chars = [1, 5, 6, 7, 8, 9, 15, 16, 19]
s = <<~EOS
Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might Also Sign Peace Security Clause. Arthur King Can.
EOS
p s.scan(/\w+/).map.with_index(1).each_with_object({}) { |(w, n), h| h[w[0...(single_chars.include?(n) ? 1 : 2)]] = n }
a = "Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might Also Sign Peace Security Clause. Arthur King Can."
b = [1, 5, 6, 7, 8, 9, 15, 16, 19]
p a.delete(".").split.map.with_index {|w, i| b.include?(i + 1) ? [w.slice(0, 1), i + 1] : [w.slice(0, 2), i + 1] }.to_h
str = "Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might Also Sign Peace Security Clause. Arthur King Can."
ret = str.gsub(/\./, '')
.split(' ')
.each_with_object({})
.with_index(1) do |(data, hash), i|
key = [1, 5, 6, 7, 8, 9, 15, 16, 19].include?(i) ? data.chars.first : data.chars[0..1].join
hash[key] = i
end
p ret
puts 'Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might Also Sign Peace Security Clause. Arthur King Can.'
.split(/[^[:alpha:]]/)
.reject(&:empty?)
.map
.with_index(1) { [[1, 5, 6, 7, 8, 9, 15, 16, 19].include?(_2) ? _1[0] : _1[0..1], _2] }
.to_h
s = "Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might Also Sign Peace Security Clause. Arthur King Can."
pos = [1, 5, 6, 7, 8, 9, 15, 16, 19]
hash = {}
i = 1
s.delete(".").split.each { |m|
a = m[0] + m[1]
if (!pos.index(i).nil?) then
a = m[0]
end
hash[a] = i
i = i + 1
}
p hash
-
まずテストコードを書いてから
-
Ruby 3.0 release event
-
上限があるので注意
- 次回、1/13(水)です
-
コロナの状況で完全オンラインになるかもしれない
-
LTは残り1枠
-
こないだMachida.rbで正規表現会をやったらしい
-
フクロウ本とかいいかも
-
正規表現入門
-
色々な書き方が見れて良かったです。 ★3
-
Ruby技術が(少し)上がっている気がする ★2
-
Ruby書くのはやっぱり楽しい ★2
-
言語処理系は使いどころ多そうで楽しかった ★2
-
遅刻してしまいました。 ★1
-
言語処理が苦手だと分かりました。 ★1
-
他の人がコードをPOSTすると焦るw ★2
-
Ruby 3.0 ★2
-
言語処理について勉強する。 ★1
-
mruby ★1
-
正規表現について勉強する。 ★2
-
次こそ議事録リアルタイム共有 ★3
-
次回は 2021/1/13(水) 19:00~ 新年会兼ねて飲食しつつ雑談その他 ★4
-
参加する ★1