cogibara 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 048368ea0cc0189cf8af873cdb7c5cbd02cfcce6
4
- data.tar.gz: cd09d2b5168568a7a5da5dd09f69e0d2ff7bf62c
3
+ metadata.gz: 5ad9864dae4e0ce82e84f8659cfb2a9597176d1d
4
+ data.tar.gz: 0ac39e5812965c0ece31f8a640debe63bd447561
5
5
  SHA512:
6
- metadata.gz: 81198a8047ab7878e82db9d44ff35bf23400591c7b97116f9b9729da4f1f42e5314ada66fff75e9066f8567a9b085a41f8cf4c6d57b9ac175b96273a873a439d
7
- data.tar.gz: 3490ccef7670287e3092324a593acb5a6f91b6331aacfeb80e41d8d854ee290b597ae9a85a1ef066608e0a96fac410650bf96b3c220f93e5df6935caccbcbcf3
6
+ metadata.gz: a2793dcb9631b658eed596366c4820edac9130a1bc7dbf2592a9b50da73ae4198352007ce65ca66747bf49a8be61b9b7584f773d2c50efcabd8f8d3cc00a163b
7
+ data.tar.gz: 15cd6d378b86e5ae0cb41996e0a42ea892351e558fd2d3dcad8242e88c387f5cdcca6673e1558ad90efda7daab5f125d2905b94fc029b3f8e07211871554300d
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # Cogibara
2
2
 
3
- ---
4
- A friendly interface to your computer and the internet, leveraging the power of natural language processing techniques used in applications such as Siri! Why let your smartphone company decide what you need your personal assistant software to do? Cogibara uses free and open source software libraries and APIs to let you ask general knowledge or math questions, manage your calendar, or just chat when you're bored. It's easy ot add new capabilites or integrate other libraries; The gem handles the infrastructure and language processing so you can focus on making your Cogibara do whatever awesome things you want it to!
3
+ Your friendly natural language interface to computer and the internet, leveraging the power of NLP techniques used in applications such as Siri! Why let your someone else decide what you need your personal assistant software to do? Cogibara uses free and open source libraries and APIs to let you ask general knowledge or math questions, manage your calendar, or just chat when you're bored. It's easy to add new capabilites or integrate other tools; The gem handles the infrastructure and language processing so you can focus on making your Cogibara do whatever awesome things you want it to!
5
4
 
6
- **NOTE**
7
- This gem is still in development, there is no documentation besides this readme, I haven't written any tests, and important things may be implemented in breathtakingly stupid ways. Feel free to point out where this is so (I'd appreciate it in fact), but you've been warned. I was planning on keeping this private for a few more months of development, but other projects have come up for the summer, so I'm releasing what I have now in case I don't get much time to work on it.
5
+ Check out the [demo client](http://goo.gl/7XOou) and its [github page](https://github.com/wstrinz/cogibara-client)! Its just something I put together with ExtJS and Rails, so it's got some bugs at the moment, but it should give you an idea of what the gem can do.
6
+
7
+ **NOTE**
8
+ This gem is still in development, there is no documentation besides this readme, I haven't written any tests, and important things may be implemented in very silly ways. Feel free [tell me](https://github.com/wstrinz/cogibara/issues) where this is so (I'd appreciate it in fact), but you've been warned. I was planning on keeping this private for a few more months of development, however other projects have come up for the summer, so I'm releasing what I have now in case I don't get much time to work on it.
8
9
 
9
10
  ## Installation
10
11
 
@@ -24,7 +25,15 @@ Or install it yourself as:
24
25
 
25
26
  The gem will install two executables; `cogibara-local` and `cogibara-redis`. Both should run fine out of the box, but many functions require an API key or account credentials to work properly. See the Configuration section for more information.
26
27
 
27
- **Cogibara Local**
28
+ **Cogibara Local**
29
+
30
+ cogibara-local -m "hows it going?"
31
+ #=> cogibara: Good and you?
32
+
33
+ cogibara-local -c config.rb -m "what time is it in the netherlands?"
34
+ #=> cogibara: 7:30:40 am CEST | Wednesday, May 29, 2013
35
+
36
+
28
37
  The `cogibara-local` executable is a command line interface for the gem.
29
38
 
30
39
  Usage: cogibara-local [options]
@@ -37,14 +46,14 @@ If a message is specifed, the executable will print the response then exit. Othe
37
46
 
38
47
  You can also call `cogibara-local` on an audio or video file (less than 10 seconds seems to work best), and it will extract the speech from it using google's Speech To Text API, then pass the result to the gem.
39
48
 
40
- **Cogibara Redis**
49
+ **Cogibara Redis**
41
50
  The `cogibara-redis` executable uses redis to allow you to design your own interfaces for the gem. For now it requires a local redis server to be installed and running, but in the near future it will allow remote redis connections as well. This could also be used to split up the work of running the gem and serving the responses between computers, giving you the ability to install a lightweight interface on something like a Raspberry Pi and leave the heavy lifting to a desktop PC.
42
51
 
43
52
  For more on how to use this executable, see the example Rails client [here](https://github.com/wstrinz/cogibara-client).
44
53
 
45
- The demo client at [cogibara.com](www.cogibara.com/mobile/talk) is, at the time of writing, running both server and client on a Raspberry Pi sitting in my living room.
54
+ The demo client at [cogibara.com](http://goo.gl/7XOou) is, at the time of writing, running both server and client on a Raspberry Pi sitting in my living room.
46
55
 
47
- **Gem API**
56
+ **Gem API**
48
57
  You can also use the gem as a part of any Ruby program
49
58
 
50
59
  require 'cogibara'
@@ -64,9 +73,9 @@ More details coming soon.
64
73
 
65
74
  Many operators require an API key to communicate with a remote service. The gems for the individual operators will have better documentation, but here's where you can get a key for the built-in modules:
66
75
 
67
- Wolfram Alpha ([gem](https://github.com/cldwalker/wolfram)): http://developer.wolframalpha.com/portal/apisignup.html
68
- Maluuba ([gem](https://github.com/Maluuba/napi-ruby/blob/master/maluuba_napi/lib/maluuba_napi.rb)): http://dev.maluuba.com/
69
- Forecast_IO ([gem](https://github.com/darkskyapp/forecast-ruby)): https://developer.forecast.io/
76
+ Wolfram Alpha ([gem](https://github.com/cldwalker/wolfram)): http://developer.wolframalpha.com/portal/apisignup.html
77
+ Maluuba ([gem](https://github.com/Maluuba/napi-ruby/blob/master/maluuba_napi/lib/maluuba_napi.rb)): http://dev.maluuba.com/
78
+ Forecast_IO ([gem](https://github.com/darkskyapp/forecast-ruby)): https://developer.forecast.io/
70
79
 
71
80
  ## Configuration
72
81
 
@@ -78,13 +87,13 @@ Although using the gem's configuration functions is more flexible, the simplest
78
87
 
79
88
  `Cogibara::dispatcher.config_from_yaml(YAML.load_file('./some_file.yml'))`
80
89
 
81
- See here for an example which will set help you set up all of the built-in modules: https://gist.github.com/wstrinz/5666591
90
+ See here for an example which will help you set up all of the built-in modules: https://gist.github.com/wstrinz/5666591
82
91
 
83
92
  ### Runtime Configuration
84
93
 
85
94
  You can call to `Cogibara::config` to fetch or update your configuration, and `Cogibara::dispatcher` to add new external operators using the following syntax:
86
95
 
87
- Cogibara::dispatcher.register_operator([mod_keywords], {name: mod_name, file_name: mod_file, class_name: mod_class_name, config: mod})
96
+ Cogibara::dispatcher.register_operator([mod_keywords], {name: mod_name, file_name: mod_file, class_name: mod_class_name, config: mod})
88
97
 
89
98
  If you do not provide an option, the dispatcher will attempt to fill it in based on the other options and various naming conventions.
90
99
 
@@ -95,33 +104,69 @@ Explanation coming soon, see examples -
95
104
  require 'cogibara'
96
105
  Cogibara.setup do |config|
97
106
  config.name = "Mr Robot"
98
- config.verbose = @verbose unless @verbose.nil?
107
+ config.verbose = true
99
108
  end
100
109
  Cogibara.setup_dispatcher do |dispatcher|
101
110
  dispatcher.register_operator(["REMINDER"],{name: "Reminder Setter"})
102
111
  dispatcher.register_operator(["chat"],{name: "Chat Bot", class_name: "Chat", file_name: "chat.rb"})
103
112
  end
104
113
 
114
+ ## Extending
115
+
116
+ It's easy to add new functionality to your Cogibara, just add a `process(message)` method to your code, and add your class or file to the list of modules using `Cogibara::dispatcher.register_operator`. You can also extend the `Cogibara::OperatorBase` class, which will allow you to utilize some built in helper methods for things like sending multiple messages and handling confirmation callbacks.
117
+
118
+ Your operator must be bound to a list of keywords or natural language categories. The Maluuba Natural Speech API, which the gem current uses for language processing, places speech into a number of different categories and extracts information such as dates and times. You can bind your operator to any category, or to any individual 'action' in a category, then handle queries and the structured information Maluuba extracts in whatver way you need to.
119
+
120
+ Cogibara can recognize both individual keywords and categories of natural speech. Keyword queries are of the form "[name] [keyword] message", and natural language queries can be hooked into using the [categories](http://dev.maluuba.com/categories) for the Maluuba API. To add a new module, either from a file or an existing Class object, simply call `Cogibara::dispatcher.register_operator(['keyword','list'],{name: "Operator Name"})`, which will attempt to load the operator based on standard Ruby naming conventions. In this case, it will be looking for a `operator_name.rb` file, or a class object called `OperatorName`. By specifying `class_name` or `file_name` options, you can override this behavior to define your own custom naming.
121
+
122
+ As an example, here's how you might go about adding an operator that tells you your current location:
123
+
124
+ require 'cogibara'
125
+ require 'geocoder'
126
+ require 'json'
127
+ require 'open-uri'
128
+ class Locator < Cogibara::OperatorBase
129
+ def process(message)
130
+ ip = 0
131
+ open( 'http://jsonip.com/ ' ){ |s| ip = JSON::parse( s.string())['ip'] }
132
+ loc = Geocoder.search(ip)
133
+ "You are in #{loc[0].city}, #{loc[0].state}!"
134
+ end
135
+ end
136
+
137
+ Cogibara.default_config
138
+
139
+ # Register operator under the 'where am I?' Maluuba speech category, and the 'location' keyword.
140
+ Cogibara::dispatcher.register_operator(['NAVIGATION_WHERE_AM_I', 'location'], {name: 'Locator'})
141
+
142
+ # natural language query
143
+ Cogibara::message_handler.handle("so where am I now?")
144
+ #=> "You are in Madison, Wisconsin!"
145
+
146
+ # keyword query
147
+ Cogibara::message_handler.handle("cogibara location")
148
+ #=> "You are in Madison, Wisconsin!"
149
+
105
150
  ## Credit
106
151
 
107
152
  This project would not be possible without the awesome gems and APIs available for free online. Here is a list of all the built in services, please let me know if I'm missing someone or you'd like your gem or service to be removed from this project.
108
153
 
109
- [speech2text gem](https://github.com/taf2/speech2text), by [Todd Fisher](https://github.com/taf)
110
- [wolfram gem](https://github.com/cldwalker/wolfram), by [Gabriel Horner](https://github.com/cldwalker)
111
- [Maluuba Natural Language API](http://dev.maluuba.com/), by [Maluuba Inc](http://www.maluuba.com/)
112
- [maluuba_napi gem](https://github.com/Maluuba/napi-ruby/blob/master/maluuba_napi/lib/maluuba_napi.rb), by [Maluuba Inc](http://www.maluuba.com/)
113
- [Forecastio API](https://developer.forecast.io/), by [Dark Sky Company](http://forecast.io/)
114
- [forecast_io gem](https://github.com/darkskyapp/forecast-ruby), by [David Czarnecki](https://github.com/czarneckid)
115
- [Cleverbot](http://www.cleverbot.com/)
116
- [cleverbot gem](https://github.com/benmanns/cleverbot), by [Benjamin Manns](https://github.com/benmanns)
117
- [bing_translator gem](https://github.com/CodeBlock/bing_translator-gem), by [Ricky Elrod](https://github.com/CodeBlock)
118
- [wikipedia-client gem](https://github.com/kenpratt/wikipedia-client), by [Ken Pratt](https://github.com/kenpratt)
119
- [sanitize gem](https://github.com/rgrove/sanitize), by [Ryan Grove](https://github.com/rgrove)
120
- [Redis](http://redis.io/)
121
- [wikicloth gem](https://github.com/nricciar/wikicloth), by [David Ricciardi](https://github.com/nricciar/wikicloth)
122
- [google_calendar gem](https://github.com/northworld/google_calendar), by [Northworld LLC](http://www.northworld.com/)
123
- [geocoder gem](https://github.com/alexreisner/geocoder), by [Alex Reisner](http://www.alexreisner.com/)
124
- [slop gem](https://github.com/injekt/slop), by [Lee Jarvis](https://github.com/injekt)
154
+ [speech2text gem](https://github.com/taf2/speech2text), by [Todd Fisher](https://github.com/taf)
155
+ [wolfram gem](https://github.com/cldwalker/wolfram), by [Gabriel Horner](https://github.com/cldwalker)
156
+ [Maluuba Natural Language API](http://dev.maluuba.com/), by [Maluuba Inc](http://www.maluuba.com/)
157
+ [maluuba_napi gem](https://github.com/Maluuba/napi-ruby), by [Maluuba Inc](http://www.maluuba.com/)
158
+ [Forecastio API](https://developer.forecast.io/), by [Dark Sky Company](http://forecast.io/)
159
+ [forecast_io gem](https://github.com/darkskyapp/forecast-ruby), by [David Czarnecki](https://github.com/czarneckid)
160
+ [Cleverbot](http://www.cleverbot.com/)
161
+ [cleverbot gem](https://github.com/benmanns/cleverbot), by [Benjamin Manns](https://github.com/benmanns)
162
+ [bing_translator gem](https://github.com/CodeBlock/bing_translator-gem), by [Ricky Elrod](https://github.com/CodeBlock)
163
+ [wikipedia-client gem](https://github.com/kenpratt/wikipedia-client), by [Ken Pratt](https://github.com/kenpratt)
164
+ [sanitize gem](https://github.com/rgrove/sanitize), by [Ryan Grove](https://github.com/rgrove)
165
+ [Redis](http://redis.io/)
166
+ [wikicloth gem](https://github.com/nricciar/wikicloth), by [David Ricciardi](https://github.com/nricciar/wikicloth)
167
+ [google_calendar gem](https://github.com/northworld/google_calendar), by [Northworld LLC](http://www.northworld.com/)
168
+ [geocoder gem](https://github.com/alexreisner/geocoder), by [Alex Reisner](http://www.alexreisner.com/)
169
+ [slop gem](https://github.com/injekt/slop), by [Lee Jarvis](https://github.com/injekt)
125
170
 
126
171
  ## Contributing
127
172
 
@@ -130,3 +175,16 @@ This project would not be possible without the awesome gems and APIs available f
130
175
  3. Commit your changes (`git commit -am 'Add some feature'`)
131
176
  4. Push to the branch (`git push origin my-new-feature`)
132
177
  5. Create new Pull Request
178
+
179
+ **A few things I'll try to get in place in the next week**
180
+ -Fix file handling (will only do transcription for now)
181
+ -An executable to listen on a local source (eg microphone). I have code for this from an earlier version of the gem, I just need to update it.
182
+ -Add Speech to Text output to configuration. Again, I also have some work done on this, so it shouldn't take too long to add back in. Espeak will be the default, but you'll be able to specify alternate engines if they're available. Currently I'm rather partial to Pico.
183
+
184
+ **Things that may have to wait/wishlist for contributions**
185
+ -RSpec tests
186
+ -Documentation; RDocs would be nice, but pages for the wiki or more details for this document would also be good.
187
+ -A better client to use by default. Preferably using a lighter weight framework such as Sinatra, and allowing easy access for mobile devices.
188
+ -Find replacements for C Extensions; there are a lot of good language processing tools for Java, so it'd be nice for this gem to be JRuby compatible.
189
+ -More offline operators. A simple request now often goes through 3 APIs; Google Speech Recognition, Maluuba's natural language processing, and whatever keyword function it hits after that. By adding support for [PocketSphinx](http://cmusphinx.sourceforge.net/2010/03/pocketsphinx-0-6-release/) and/or something link [LingPipe](http://alias-i.com/lingpipe/) would speed up response times enormously.
190
+ -More operators in general, and improve the current ones. For example, the weather operator only gives current conditions and the days forecast, but it could easily be extended to handle more specific queries using the information extracted by Maluuba.
data/bin/cogibara-local CHANGED
@@ -32,18 +32,18 @@ def parse
32
32
 
33
33
  @verbose = opts.verbose?
34
34
  @msg = opts[:message]
35
- @name = opts[:name] || "cucumber"
35
+ @name = opts[:name] || "cogibara"
36
36
  @config_file = opts[:config]
37
37
 
38
38
  if !@msg
39
39
  if @config_file
40
40
  @verbose = false
41
- @name = "cucumber"
41
+ @name = "cogibara"
42
42
  configure
43
43
  text_loop
44
44
  else
45
45
  @msg = ARGV.join(' ')
46
- @name = "cucumber"
46
+ @name = "cogibara"
47
47
  @verbose = false
48
48
  end
49
49
  end
data/bin/cogibara-redis CHANGED
@@ -6,14 +6,14 @@ require 'redis'
6
6
  @red = Redis.new
7
7
 
8
8
  Cogibara.setup do |config|
9
- config.name = "cucumber"
9
+ config.name = "cogibara"
10
10
  end
11
11
 
12
12
  if ARGV[0]
13
13
  load "./#{ARGV[0]}"
14
14
  else
15
15
  Cogibara.default_config
16
- end
16
+ end
17
17
 
18
18
  Redis.new.subscribe(:toCapy) do |on|
19
19
  on.message do |channel, msg|
@@ -8,6 +8,6 @@ class Help < Cogibara::OperatorBase
8
8
  soft_operators = operators.reject{ |o| o.upcase != o}
9
9
  hard_operators = operators
10
10
 
11
- "I understand the following categories of natural speech: #{soft_operators}, and keyword queries of the form <my name>: #{hard_operators}. Most natural speech categories implement a more natural response, so, for example, 'what is 18 dollars in rupees' activates the knowledge module, and returns 'rupee 968.31(Indian rupees)', while the 'ask' keyword sends the query to the knowledge engine and prints raw output, so 'cucumber ask what is 18 dollars in rupees' = 'Input Interpretation: convert $18 (US dollars) to Indian rupees, Result: rupee968.31 (Indian rupees), 1-year minimum | rupee931.42 (October 4, 2012 | 7 months ago) 1-year maximum | rupee1030.38 (June 24, 2012 | 10 months ago)"
11
+ "I understand the following categories of natural speech: #{soft_operators}, and keyword queries of the form #{Cogibara::config.name}: #{hard_operators}. Most natural speech categories implement a more natural response, so, for example, 'what is 18 dollars in rupees' activates the knowledge module, and returns 'rupee 968.31(Indian rupees)', while the 'ask' keyword sends the query to the knowledge engine and prints raw output, so 'cucumber ask what is 18 dollars in rupees' = 'Input Interpretation: convert $18 (US dollars) to Indian rupees, Result: rupee968.31 (Indian rupees), 1-year minimum | rupee931.42 (October 4, 2012 | 7 months ago) 1-year maximum | rupee1030.38 (June 24, 2012 | 10 months ago)"
12
12
  end
13
13
  end
@@ -1,3 +1,3 @@
1
1
  module Cogibara
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -0,0 +1,6 @@
1
+ require 'yaml'
2
+ Cogibara.setup_dispatcher do |dispatcher|
3
+ yml = YAML.load_file('/home/wstrinz/Documents/Projects/speechrecog/config.yml')
4
+ dispatcher.config_from_yaml(yml)
5
+ # dispatcher.register_operator(["REMINDER"],{name: "Reminder Setter"})
6
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cogibara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - wstrinz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-29 00:00:00.000000000 Z
11
+ date: 2013-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -291,6 +291,7 @@ files:
291
291
  - lib/cogibara/text_parser.rb
292
292
  - lib/cogibara/transcriber.rb
293
293
  - lib/cogibara/version.rb
294
+ - tempfile-136980540654057
294
295
  homepage: https://github.com/wstrinz/cogibara
295
296
  licenses:
296
297
  - MIT