NLP For Rubyists

2020-02-27 144浏览

  • 1.NLP For Rubyists Aja Hammerly @the_thagomizer 1
  • 2.Aja Hammerlyhttp://github.com/thagomizer@the_thagomizerhttp://www.thagomizer.com
  • 3.Lawyer CatSays:Any code is copyright Google and licensed Apache V2 @the_thagomizer
  • 4.
  • 5.NLP?!?! @the_thagomizer 5
  • 6.Natural Language Processing @the_thagomizer 6
  • 7.Natural language processing (NLP) is a field of computer science, artificial intelligence, and computational linguistics concerned with the interactions between computers and human (natural) languages and, in particular, concerned with programming computers to fruitfully process large natural language corpora. 
 - Wikipedia @the_thagomizer 7
  • 8.Teaching computers to understand (and ideally respond to) human languages. - Aja @the_thagomizer 8
  • 9.Why Should I Care? @the_thagomizer 9
  • 10.It Is Already Here @the_thagomizer 10
  • 11.Better User Experience @the_thagomizer 11
  • 12.@the_thagomizer 12
  • 13.@the_thagomizer 13
  • 14.@the_thagomizer 14
  • 15.Accessibility @the_thagomizer 15
  • 16.Improved Understanding @the_thagomizer 16
  • 17.Assist Us @the_thagomizer 17
  • 18.Hard @the_thagomizer 18
  • 19.Why Is This Hard? @the_thagomizer 19
  • 20.English Is Horrible @the_thagomizer 20
  • 21.Seal @the_thagomizer 21
  • 22.@the_thagomizer 22
  • 23.@the_thagomizer 23
  • 24.Their
 There They're @the_thagomizer 24
  • 25.Love @the_thagomizer 25
  • 26.English is Horrible @the_thagomizer 26
  • 27.All Human Languages Are Horrible @the_thagomizer 27
  • 28.No Computational Grammar @the_thagomizer 28
  • 29.@the_thagomizer 29
  • 30.I'm Starving @the_thagomizer 30
  • 31.You look freezing. @the_thagomizer 31
  • 32.Unique @the_thagomizer 32
  • 33.Computers Suck
 at Sarcasm @the_thagomizer 33
  • 34.Sure, I'd love to. @the_thagomizer 34
  • 35.Why Is This Hard? @the_thagomizer 35
  • 36.@the_thagomizer 36
  • 37.History @the_thagomizer 37
  • 38.Leibniz & Descartes @the_thagomizer 38
  • 39.The Turing Test @the_thagomizer 39
  • 40.ELIZA @the_thagomizer 40
  • 41.Chat Bots @the_thagomizer 41
  • 42.Show Me The Codes @the_thagomizer 42
  • 43.Impractical @the_thagomizer 43
  • 44.Twitter @the_thagomizer 44
  • 45.@the_thagomizer e r o M % s 0 a 1 e 1 d I d a B E L A C S T A
  • 46.sen·ti·ment a·nal·y·sis (noun) the process of computationally identifying and categorizing opinions expressed in a piece of text, especially in order to determine whether the writer's attitude towards a particular topic, product, etc., is positive, negative, or neutral. @thagomizer_rb
  • 47.👿 -30 @the_thagomizer 💩 -15 ❤😀 ! 0 15 30
  • 48.Google Cloud Natural Language API @the_thagomizer 48
  • 49.gem install google-cloud language @the_thagomizer 49
  • 50.require "google/cloud/language" language =Google::Cloud::Language.newdef analyze tweet document = language.document tweet sentiment = document.sentiment sentiment.score end @the_thagomizer 50
  • 51.Hand Wave @the_thagomizer 51
  • 52.Demo @the_thagomizer 52
  • 53.#railsconf @the_thagomizer 53
  • 54.Sentence Diagramming @the_thagomizer 54
  • 55.ate fish Th e cat @the_thagomizer 55
  • 56.ate cat fish The @the_thagomizer 56
  • 57.Eww! Grammar. @the_thagomizer 57
  • 58.Side Quest!!!! Grammar 101 @the_thagomizer 58
  • 59.Parts of Speech @the_thagomizer 59
  • 60.Verb @the_thagomizer 60
  • 61.Action @the_thagomizer 61
  • 62.@the_thagomizer 62
  • 63.State of Being @the_thagomizer 63
  • 64.@the_thagomizer 64
  • 65.Noun @the_thagomizer 65
  • 66.Person @the_thagomizer 66
  • 67.@the_thagomizer 67
  • 68.Place @the_thagomizer 68
  • 69.@the_thagomizer 69
  • 70.Thing @the_thagomizer 70
  • 71.@the_thagomizer 71
  • 72.Idea @the_thagomizer 72
  • 73.@the_thagomizer 73
  • 74.Adjective @the_thagomizer 74
  • 75.Attributes @the_thagomizer 75
  • 76.Compare @the_thagomizer 76
  • 77.Article @the_thagomizer 77
  • 78.Determiner @the_thagomizer 78
  • 79.Parts of a Sentence @the_thagomizer 79
  • 80.Root @the_thagomizer 80
  • 81.Subject @the_thagomizer 81
  • 82.Direct Object @the_thagomizer 82
  • 83.The cat eats fish. @the_thagomizer 83
  • 84.direct object subject The cat eats fish. root @the_thagomizer 84
  • 85.Side Quest Complete @the_thagomizer 85
  • 86.Sentence Diagramming @the_thagomizer 86
  • 87.Subject Direct Object her Ot her Ot @the_thagomizer Verb 87
  • 88.Syntax @the_thagomizer 88
  • 89.require "google/cloud/language" l =Google::Cloud::Language.newd = l.document("The cat ate fish.") s = d.syntax puts s.tokens @the_thagomizer 89
  • 90., @text_span= #> @the_thagomizer 90
  • 91., @text_span= #> @the_thagomizer 91
  • 92., @text_span= #> @the_thagomizer 92
  • 93., @text_span= #> @the_thagomizer 93
  • 94.require "google/cloud/language" language =Google::Cloud::Language.newsyn = language.document("The cat ate fish.").syntax subj = syn.tokens.find { t t.label == :NSUBJ }.text_span.text verb = syn.tokens.find { t t.label == :ROOT }.text_span.text puts "#{subj} #{verb}" puts "----------------" puts "#{" " * subj.size} " @the_thagomizer 94
  • 95.require "google/cloud/language" l =Google::Cloud::Language.newsyn = l.document("The cat ate fish.").syntax subj = syn.tokens.find { t t.label == :NSUBJ }.text_span.text verb = syn.tokens.find { t t.label == :ROOT }.text_span.text puts "#{subj} #{verb}" puts "----------------" puts "#{" " * subj.size} " @the_thagomizer 95
  • 96.require "google/cloud/language" l =Google::Cloud::Language.newsyn = l.document("The cat ate fish.").syntax subj = syn.tokens.find { t t.label == :NSUBJ }.text_span.text verb = syn.tokens.find { t t.label == :ROOT }.text_span.text puts "#{subj} #{verb}" puts "----------------" puts "#{" " * subj.size} " @the_thagomizer 96
  • 97.require "google/cloud/language" l =Google::Cloud::Language.newsyn = l.document("The cat ate fish.").syntax subj = syn.tokens.find { t t.label == :NSUBJ }.text_span.text verb = syn.tokens.find { t t.label == :ROOT }.text_span.text puts "#{subj} #{verb}" puts "----------------" puts "#{" " * subj.size} " @the_thagomizer 97
  • 98.require "google/cloud/language" l =Google::Cloud::Language.newsyn = l.document("The cat ate fish.").syntax subj = syn.tokens.find { t t.label == :NSUBJ }.text_span.text verb = syn.tokens.find { t t.label == :ROOT }.text_span.text puts "#{subj} #{verb}" puts "----------------" puts "#{" " * subj.size} " @the_thagomizer 98
  • 99.cat ate ---------- @the_thagomizer 99
  • 100.subj = syn.tokens.find { t t.label == :NSUBJ }.text_span.text verb = syn.tokens.find { t t.label == :ROOT }.text_span.text dobj = syn.tokens.find { t t.label == :DOBJ }.text_span.text puts "#{subj} #{verb} #{dobj}" puts "#{"-" * (subj.size + verb.size + dobj.size + 7)}" puts "#{" " * subj.size} " @the_thagomizer 100
  • 101.cat ate fish --------------- @the_thagomizer 101
  • 102.The cat eats fish. @the_thagomizer 102
  • 103.#, @text_span= #> @the_thagomizer 103
  • 104.[The, cat, eats, fish, .] @the_thagomizer 104
  • 105.tokens.each do t if tokens[t.head_token_index] == subj print t.text_span.text end end @the_thagomizer 105
  • 106.cat ate fish ----------------The @the_thagomizer 106
  • 107.The cat at the fish with a side of milk. @the_thagomizer 107
  • 108.graph @the_thagomizer 108
  • 109.node(id, label) @the_thagomizer 109
  • 110.edge(to, from) @the_thagomizer 110
  • 111.require "google/cloud/language" require "graph" l =Google::Cloud::Language.newtokens = l.document("The cat ate fish.").syntax.tokens digraph do tokens.each_with_index do t, i node(i, t.text_span.text) unless t.head_token_index == i edge(i, t.head_token_index) end end save "sentence4", "png" end @the_thagomizer 111
  • 112.require "google/cloud/language" require "graph" l =Google::Cloud::Language.newtokens = l.document("The cat ate fish.").syntax.tokens digraph do tokens.each_with_index do t, i node(i, t.text_span.text) unless t.head_token_index == i edge(i, t.head_token_index) end end save "sentence4", "png" end @the_thagomizer 112
  • 113.require "google/cloud/language" require "graph" l =Google::Cloud::Language.newtokens = l.document("The cat ate fish.").syntax.tokens digraph do tokens.each_with_index do t, i node(i, t.text_span.text) unless t.head_token_index == i edge(i, t.head_token_index) end end save "sentence4", "png" end @the_thagomizer 113
  • 114.require "google/cloud/language" require "graph" l =Google::Cloud::Language.newtokens = l.document("The cat ate fish.").syntax.tokens digraph do tokens.each_with_index do t, i node(i, t.text_span.text) unless t.head_token_index == i edge(i, t.head_token_index) end end save "sentence4", "png" end @the_thagomizer 114
  • 115.require "google/cloud/language" require "graph" l =Google::Cloud::Language.newtokens = l.document("The cat ate fish.").syntax.tokens digraph do tokens.each_with_index do t, i node(i, t.text_span.text) unless t.head_token_index == i edge(i, t.head_token_index) end end save "sentence4", "png" end @the_thagomizer 115
  • 116.@the_thagomizer 116
  • 117.@the_thagomizer 117
  • 118.Silly Examples @the_thagomizer 118
  • 119.Practical @the_thagomizer 119
  • 120.Free @the_thagomizer 120
  • 121.Google at RailsConf •Talks:• Google Cloud <3 Ruby (watch on ConFreaks) • What's My App *Really* Doing in Production • Thursday @ 3:30 in Rm 156 • Raffle for a GoogleHome:•Booth:Codelabs. Stickers. Answers. @the_thagomizer 121
  • 122.Thank You @the_thagomizer 122
  • 123.Questions? @the_thagomizer 123