Giter VIP home page Giter VIP logo

skitelman / wolfram-alpha Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mkroman/wolfram-alpha

0.0 2.0 0.0 153 KB

Wolfram|Alpha introduces a fundamentally new way to get knowledge and answers – not by searching the web, but by doing dynamic computations based on a vast collection of built-in data, algorithms, and methods.

Home Page: http://rubydoc.info/github/mkroman/wolfram-alpha

Ruby 100.00%

wolfram-alpha's Introduction

WolframAlpha

Wolfram|Alpha introduces a fundamentally new way to get knowledge and answers— not by searching the web, but by doing dynamic computations based on a vast collection of built-in data, algorithms, and methods.

Installation

gem install wolfram-alpha

And that's it!

Usage

Creating a client instance:

require 'wolfram-alpha'

options = { "format" => "plaintext" } # see the reference appendix in the documentation.[1]

client = WolframAlpha::Client.new "MY-API-ID", options

External links:

  1. WolframAlpha API: Documentation

Querying the engine:

response = client.query "5 largest countries"

Handling responses:

input = response["Input"] # Get the input interpretation pod.
result = response.find { |pod| pod.title == "Result" } # Get the result pod.

puts "#{input.subpods[0].plaintext} = #{result.subpods[0].plaintext}"

# 5 largest countries | by total area = 1 | Russia | 1.708×10^7 km^2 |
# 2 | Canada | 9.985×10^6 km^2 |
# 3 | United States | 9.631×10^6 km^2 |
# 4 | China | 9.597×10^6 km^2 |
# 5 | Brazil | 8.515×10^6 km^2 |
# (vertical ellipsis) |   |   |

Beware that WolframAlpha::Response#[] is finding a pod by its id, and not by its title.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

History

v0.3

  • Refactored the API.
  • Tidied up the code.

v0.2

  • Fixed query escaping.
  • Added documentation.

v0.1

  • Initial release.

Credits

Mikkel Kroman <[email protected]>

License

Copyright (c) 2013 Mikkel Kroman <[email protected]>

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

wolfram-alpha's People

Contributors

mkroman avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.