Ruby and japanese
-
Upload
makoto-inoue -
Category
Documents
-
view
6.463 -
download
0
Transcript of Ruby and japanese
![Page 1: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/1.jpg)
RUBY AND JAPANESEルビーと日本語
Makoto Inoue LRUG December 2010
![Page 2: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/2.jpg)
WHO ARE WE(NORMAL)?
![Page 3: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/3.jpg)
WHO ARE WE(TODAY)?
![Page 4: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/4.jpg)
ME @ RUBYKAIGI
http://image.gihyo.co.jp/assets/images/news/report/01/rubykaigi2010/0003/thumb/TH400_IMG_1253.jpg
here
![Page 5: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/5.jpg)
TOPIC
Basic Japanese
Object Oriented (OO)
Functional
Japanese Programming in Ruby
![Page 6: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/6.jpg)
BASIC JAPANESE日本語の基礎
Step 1
![Page 7: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/7.jpg)
WATASHI HA RUBY GA SUKI DESU私はルビーが好きです
Kanji 漢字 ( eg: 私,好 )
Katakanaカタカナ( eg: ルビー )
Hiraganaひらがな( eg:は ,が,きです)
Kanji Katakana Hiragana
![Page 8: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/8.jpg)
Hiragana
Katakana
Each Japanese alphabet is a combination of vowels(a,i,u,e,o) and consonants(k,s,t,n,h,m,y,r,w). Total of Hiragana and Katakana are 46 each. The number of possible Kanji in use in Japan is around 50,000 , though around 2000 ~ 3000 are in common use.
![Page 9: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/9.jpg)
Kanji => Hiragana
Kanji
Hiragana
![Page 10: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/10.jpg)
Kanji => KatakanaKanji
Katakana
![Page 11: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/11.jpg)
Makoto makoto マコト まこと 真
Vivian bibiann ビビアン びびあん
Oliver oriba- オリバー おりばー
Max makkusu マックス まっくす
WHAT’S YOUR NAME?お名前は?
Alphabet How Japanese interpret Katakana Hiragana Kanji
![Page 13: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/13.jpg)
WHY SO MANY WAYS?
Kanji = To import Chinese words
Hiragana = To suit for domestic use
Katakana = To adopt new words
![Page 14: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/14.jpg)
WHY SO MANY WAYS?
To import OO & Functional
To suit for Scripting
To adopt New Concepts
![Page 15: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/15.jpg)
OBJECT ORIENTEDオブジェクト指向
Step 2
![Page 16: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/16.jpg)
JAPANESE & OO
http://satoshi.blogs.com/life/2004/09/post.html
![Page 17: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/17.jpg)
ENGLISH (SVO)
I like Ruby
Subject Verb Object
![Page 18: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/18.jpg)
日本語(SOV)
私はルビーが好きですWatashi ha Ruby ga Suki desu
Subject Object Verb
I Ruby Like
![Page 19: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/19.jpg)
CUI(SVO)
![Page 20: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/20.jpg)
GUI(SOV)http://satoshi.blogs.com/life/2004/09/post.html
![Page 21: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/21.jpg)
RUBY
# Proceduralopen("box")open("car")
# OOBox.new.openCar.new.open
![Page 22: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/22.jpg)
FUNCTIONAL関数型
Step 3
![Page 23: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/23.jpg)
Japanese is a politician's language
日本語は政治家向けの言語である
Makoto Inoue (Me) - 2010
![Page 24: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/24.jpg)
POLITICIAN....
does not commit to anything unless necessary
means different things depending on context
![Page 25: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/25.jpg)
PREPOSITIONS前置詞
preposition |ˌprepəˈzi sh ən|noun Grammara word governing, and usually preceding, a noun or pronoun and expressing a relation to another word or element in the clause, as in “the man on the platform,” “she arrived after dinner,” “what did you do it for you
![Page 26: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/26.jpg)
POSTPOSITIONS助詞
postposition |ˌpōstpəˈzi sh ən|noun Grammara word or morpheme placed after the word it governs, for example -ward in homeward.
![Page 27: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/27.jpg)
POSTPOSITIONS IN JAPANESE助詞(て に を は が)
私はルビーが好きですWatashi ha Ruby ga Suki desu(I Ruby Like)
ルビーが私は好きですRuby ga Watashi ha Suki desu(Ruby I Like)
ルビーが好きですRuby ga Suki desu(Ruby Like)
Postposition is used to decide the role of noun which it supports. This enables you to change the order of structure very flexibly, chain as many sentence as you like, and also let you to omit subject.
O
SO
S
O
![Page 28: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/28.jpg)
ABUSING POSTPOSITIONS助詞の乱用
”もし 有権者の皆様が私に投票してくださり、な
おかつ必要な財源を期日内に確保することができ
ましたならば、みなさまのご期待に添う事が出来
るよう、政治生命を賭けて戦って行く所存でござ
います。”
Don’t Read !!
Confusing, vague, and long sentence without much point
(Could be powerful)
![Page 29: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/29.jpg)
FUNCTIONAL
Lazy evaluation
high order function
![Page 30: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/30.jpg)
RUBY
Enumerable
Arel
Block
User.order('users.id DESC').limit(20).includes(:items)
% 10000.times=> #<Enumerator: 10000:times>
File.open("/tmp.txt").each do |line| puts lineend
![Page 31: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/31.jpg)
JAPANESE PROGRAMMING IN RUBY
RUBYで日本語プログラミングhttps://github.com/makoto/japanize1.9 Step 4
![Page 33: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/33.jpg)
GRAMMAR
# -*- encoding: utf-8 -*-module Japanize module Grammar VERBS = { 'たす' => :+, # tasu 'ひく' => :-, # hiku 'かける' => :*, # kakeru 'わる' => :/, # waru } POSTPOSITIONAL_PARTICLES = ['て','に','を','は'] def 助詞; POSTPOSITIONAL_PARTICLES; end def 数字; NUMBERS; end def 動詞; VERBS; end
![Page 34: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/34.jpg)
GRAMMAR
# -*- encoding: utf-8 -*- def parse @sequence.split('').map do |s| s.split(/#{助詞.join("|")}/) end.flatten.map do |s| if 動詞[s] 動詞[s] elsif 数字[s[0]] NumberConverter.convert(s) end end end
![Page 35: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/35.jpg)
PARSER
# -*- encoding: utf-8 -*-describe Parser do it "must divide a phrase into words" do Parser.new("1に2をたして4を掛ける"). parse.must_equal [1, 2, :+, 4, :*] endend
![Page 36: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/36.jpg)
GOOGLE TRANSLATION
![Page 37: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/37.jpg)
EVALUATOR
describe Evaluator do it "must calculate all operands" do Evaluator.new([1, 2, :+, 3 , :* , 1, :-, 2, :/]). evaluate.must_equal ((((1+2) * 3) - 1 ) / 2) endend
![Page 38: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/38.jpg)
REVERSE POLISH NOTATION逆ポーランド記法
http://en.wikipedia.org/wiki/Reverse_Polish_notation
[1, 2, :+, 3 , :* , 1, :-, 2, :/]
![Page 39: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/39.jpg)
RubiMaVM RUBY VM ON RUBY
http://jp.rubyist.net/magazine/?0007-YarvManiacs
![Page 40: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/40.jpg)
METHOD MISSING
# -*- encoding: utf-8 -*-def method_missing (*obj) if 数字[obj[0][0]] parsed = Parser.new(obj[0].to_s).parse Evaluator.new(parsed).evaluate else super endend
![Page 41: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/41.jpg)
![Page 42: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/42.jpg)
SO WHAT?っで?
:-)
![Page 43: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/43.jpg)
WHY SO MANY WAYS?
To import OO & Functional
To suit for Scripting
To adopt New Concepts
![Page 44: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/44.jpg)
MATZ @SAPPORO RUBY KAIGI
”In future, I want Ruby to keep being the light
which brings new concepts and ideas to people.
I also would like people to see such light, add their own, and spread it to other people.”
http://regional.rubykaigi.org/sapporo03
http://igarashikuniaki.net/tdiary/20101205.html
![Page 45: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/45.jpg)
WHAT CAN YOU DO?http://www.igvita.com/2010/12/02/concurrency-with-actors-goroutines-ruby/
http://rubykaigi.org/2011/enhttp://www.rubyinside.com/ruby-refinements-an-overview-of-a-new-proposed-ruby-feature-3978.html
http://www.pragprog.com/titles/btlang/seven-languages-in-seven-weeks
![Page 46: Ruby and japanese](https://reader033.fdocuments.in/reader033/viewer/2022052523/55516f01b4c905723b8b4b29/html5/thumbnails/46.jpg)
MERRY CHRISTMAS & HAVE A HAPPY NEW YEAR!!メリークリスマス&良いお年を!!
http://www.railsonwave.com/assets/2006/12/21/screensaver_1.jpg
hello 2011