GithubHelp home page GithubHelp logo

molybdenum-99 / reality Goto Github PK

View Code? Open in Web Editor NEW
812.0 26.0 47.0 5.73 MB

Comprehensive data proxy to knowledge about real world

License: MIT License

Ruby 100.00%
opendata knowledge api wikipedia experimental

reality's Introduction

Reality

Gem Version Join the chat at https://gitter.im/molybdenum-99/reality

Reality is experimental Ruby library/set of libraries to provide uniform query access to heterogenous web API, with accent on real-world knowledge ones. It emphasizes simplicity of data access and interoperability of data from various sources.

The ultimate goal is to make the world inspectable and computable.

Some demos:

require 'reality' # the core library
require 'reality/miracles' # some demo-friendly shortcuts

# wikipedia

# single entry
cm = Reality.wikipedia.get('Chiang Mai')
# => #<Reality::Entity wikipedia:en://Chiang Mai>

cm.describe
# => #<Reality::Entity wikipedia:en://Chiang Mai>
#                   meta.title: Chiang Mai
#                     meta.url: https://en.wikipedia.org/wiki/Chiang_Mai
#                   meta.image: https://upload.wikimedia.org/wikipedia/commons/7/76/Chiang_Mai_City.png
# ....
#                  native_name: เชียงใหม่
# ....
#             subdivision_type: Country
#             subdivision_name: <wikipedia:en://Thailand>
#            subdivision_type1: <wikipedia:en://Provinces of Thailand (Province)>
#            subdivision_name1: <wikipedia:en://Chiang Mai Province>
#            subdivision_type2: <wikipedia:en://Amphoe>
#            subdivision_name2: <wikipedia:en://Mueang Chiang Mai District (Mueang Chiang Mai)>
#                 leader_title: Mayor
#                  leader_name: Tatsanai Puranupakorn
#               area_total_km2: 40.22km²
#               area_metro_km2: 2,905km²
#             population_as_of: 2017
#             population_total: 131,091people
# ....
#                   utc_offset: +07:00
#                  coordinates: 18°47'43"N 98°59'55"E
# .....

# navigation through data
cm.subdivision_name.describe
# => #<Reality::Entity wikipedia:en://Thailand>
#               meta.title: Thailand
#                 meta.url: https://en.wikipedia.org/wiki/Thailand
#               meta.image: https://upload.wikimedia.org/wikipedia/commons/a/a9/Flag_of_Thailand.svg
#              native_name: {native name:th|ราชอาณาจักรไทย}, {lang:th-Latn|Ratcha-anachak Thai}
#               image_flag: <wikipedia:en://File:Flag of Thailand.svg>
#               image_coat: <wikipedia:en://File:Garuda Emblem of Thailand.svg>
#          national_anthem: <wikipedia:en://Thai National Anthem (Phleng Chat Thai)>, ({lang-en:"Thai National Anthem"}),
#             royal_anthem: <wikipedia:en://Sansoen Phra Barami>, ({lang-en:"Glorify His prestige"}),
#                image_map: <wikipedia:en://File:Location Thailand ASEAN.svg>
# ....
#                  capital: <wikipedia:en://Bangkok>
#              coordinates: 13°45'0"N 100°29'0"E
# ....

# lists of entities
cities = Reality.wikipedia.query(category: 'Cities and towns in Thailand').all
# => [#<Reality::Link wikipedia:en://Amnat Charoen>, #<Reality::Link wikipedia:en://Bueng Kan>, #<Reality::Link wikipedia:en://Buriram>, #<Reality::Link wikipedia:en://Cha-am District>, #<Reality::Link wikipedia:en://Chai Nat>, #<Reality::Link wikipedia:en://Chai Prakan>, #<Reality::Link wikipedia:en://Chaiyaphum>, #<Reality::Link wikipedia:en://Chiang Dao Subdistrict>, #<Reality::Link wikipedia:en://Chiang Mai>, ...
cities.first.population_total
# => #<Reality::Measure 26,118 people>

# Wikidata (structured Wikipedia-alike data storage)
cm2 = Reality.wikidata.query(label: 'Chiang Mai').first
# => #<Reality::Link wikidata://Q52028 (Chiang Mai)>
cm2.describe
# => #<Reality::Entity wikidata://Q52028>
#                                  meta.id: Q52028
#                               meta.label: Chiang Mai
#                         meta.description: city in Chiang Mai province, Thailand
#  ...
#                              instance of: <wikidata://Q15141632 (Thesaban Nakhon)>, <wikidata://Q1549591 (big city)>
#  ...
#                              sister city: <wikidata://Q819613 (Uozu)>, <wikidata://Q128186 (Saitama Prefecture)>, <wikidata://Q182852 (Kunming)>, <wikidata://Q42956 (Harbin)>
#                              GeoNames ID: 1153671
#            category for people born here: <wikidata://Q8078994>
# category for films shot at this location: <wikidata://Q7140299 (Category:Films shot in Chiang Mai)>
#        category for people who died here: <wikidata://Q27062063>
#        Encyclopædia Britannica Online ID: place/Chiang-Mai
# ...

# Interaction Wikipedia→Wikidata:
cm = Reality.wikipedia.get('Chiang Mai')
cm['meta.wikidata'].load.describe
# => #<Reality::Entity wikidata://Q52028>
#    meta.id: Q52028
# meta.title: Q52028
# meta.label: Chiang Mai
# ...

# Wikipedia→OpenStreetMap
Reality.osm.query(around: cm, radius: 30_000, aerodrome: 'international').all
# => [#<Reality::Link osm://way(90429204) (Chiang Mai International Airport)>]

# Wikipedia→OpenWeatherMap
Reality.open_weather_map.query(at: cm).first.describe
# => #<Reality::Entity openweathermap://1153671>
#       temp: 33°C
#   pressure: 1,007hPa
#   humidity: 55%
#   temp_min: 33°C
#   temp_max: 33°C
# visibility: 10000
# wind_speed: 4.6m/s
#   wind_deg: 160°
# clouds_all: 40
#  timestamp: 2018-05-27 13:00:00 +0300
#    country: TH
#    sunrise: 2018-05-27 01:46:48 +0300
#     sunset: 2018-05-27 14:55:42 +0300
#       name: Chiang Mai
#      coord: 18°48'0"N 99°0'0"E

!!!IMPORTANT!!! This is pre-release of new, completely rewritten version. Previos version turned to be a (nice-looking) dead end. It still can be found at old-prototype branch, and installed as a gem version 0.0.5.

Current state is very WIP subject to lot of changes

See also the explanatory presentation and video, made at RubyConfIndia 2018.

Stay tuned for large and important updates!

Credits

Development of first version was sponsored by 2015 Ruby Association Grant.

Initial idea is inspired by "integrated data" of Wolfram Language.

License

MIT

reality's People

Contributors

am-kantox avatar cmarat avatar codenamev avatar gitter-badger avatar kraken-ua avatar smostovoy avatar vessi avatar zverok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reality's Issues

WikiData: lists

  • Use RDF query-fu;
  • It seems we still need fallback to Wikipedia (for ex, list of countries, or spoken languages);

Country concept

# Fetching
Reality.country('Ukraine')   # should return something of type Reality::Country
Reality.country('Uranus')    # should return nil... or raise some NotFound-y exception?
  • Country should have at least some of useful methods from country infobox: https://en.wikipedia.org/wiki/Ukraine;
  • methods like captial or currency should return some kind of generic Reality::Entity (showing it will be further queriable) -- or only in next versions?
  • complex properties like leaders (concept of President of Ukraine + personality of Petro Poroshenko, concept of Prime Minister + personality) should also behave decently!

In fact, first task here is to write several "pretty" showscase-y specs, the simplest ones -- and then implement them.

More fields for Country

(Tickets like this will appear in mass... So, need something to organize them)

  • largest cities
  • indices (GDP, Gini, and so on)
  • motto, anthem, flag (links, later: media)
  • neighbours (warning: really TRICKY with Wikipedia!)
  • legislature (title only?)
  • sovereignty_type?, government type?
  • geoposition (in infobox looks like |latd=19 |latm=03 |lats=31.94 |latNS=S |longd=169 |longm=52 |longs=31.48 |longEW=W)
  • and so on

Entity#time_zone

Incorporate some time zone calculations library, for things like city('Paramaribo').time_zone.current_time

Historically timed data

At least two cases I can think of:

1.

Reality.country('Argentina').leaders(at: 2009) 

Using molybdenum-99/infoboxer#54, extracts old revision of "Argentina" article from Wikipedia, takes data from there.

2.

fdr = Reality.person('Franklin D. Roosevelt')
fdr.occupation 
# => large structure with titles and dates: president, vice-president, senator...
fdr.occupation(at: 1914) 
# => "Assistant Secretary of the Navy", extracted from the structure

Disambiguator

  1. Entity('Bush') should return special Disambiguator class, which provides inspect for "what variants there are", and allows to select between them easily.
  2. Entity('Ruby') should have other_uses method (providing contents of Ruby (disambiguation) page as Disambiguator)

Measure: time math

Seems to be implemented in multiple other libraries, so just use them/import code:

Measure(1, 'h').since # => Time.now + 1 hour
Measure(1, 'h').ago   # => Time.now - 1 hour

...and so on.

More lists in Dictionaries

At least, we need planets! The reality doesn't end in Earth atmosphere.
Also.. the number of things-to-be-listed will be updated soon.

More Wikidata predicates

Full list is here: https://github.com/molybdenum-99/reality/blob/master/data/wikidata-predicates.yaml

Add reasonable number of interesting ones.

Code for checking how much of entities uses predicate in web console:

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/> 
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX v: <http://www.wikidata.org/prop/statement/>

SELECT ?id ?idLabel ?o ?oLabel  WHERE {
  ?id wdt:P1884 ?o .
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
  }
 } limit 100

(replace P1884 with your value).

Generalized Entity

English Wikipedia should be considered a primary source. Reality.entity('Mahatma Gandhi') should provide at least some data like "description" (first paragraph of Wikipedia article) and "type" (guessed from infobox), and try to provide more for "common" knowledge types.

Any link from Entity (through infobox field) should fetch an Entity. If the latter is of known sub-type (like country or city) -- object of corresponding subclass should be fetched.

Entity caching

First take: eternal cache with manual cleanup.

  1. Cache is opt-in (should be explicitly turned on through config or Reality.cache!)
  2. Cache path should be configured (with reasonable default somewhere in /tmp?..)
  3. Each entity is cached by name, in two separate file: wikipedia data & wikidata data (we cache source, not parsed entity, because after adding new parsers richer data can be extracted from same cached source; drawback is parsing speed)
  4. There should be way to query if entity is from cache or from the wild (or, alternatively, how old is it)
  5. Dictionaries (lists) caching.

In future, we should consider:

  • TTL settins (even per-entity);
  • Explicity refreshing entity or invalidating cache;
  • Methods, if possible, for meta-query Wikipedia/Wikidata "if the page changed" (for cached pages), and load them only in this case.

Browser Extension

First of all, really cool!

For the last couple years I've always been thinking about a lot when it comes to "semantic" understanding of real world entities. I got that excitement from my first internship at now defunct company called Apture.

A little later, I've actually tried to create an extension of mine in https://github.com/nambrot/erutpa. However, I abandoned it quite shortly after due to a lack of reliable data sources as I used Freebase.

I really love the concept behind Reality as I see a lot of similar ideas and was wondering if there was any plan to make this into a user-product. I very often find myself wanting to understand an Entity when im reading something and having something like Reality power that something would be amazing

Enchance configuration

  1. It should be possible to configure executable with reality --config reality.yml
  2. Consider using "current folder" trick like other tools, e.g. if reality binary run in folder containing .reality.yml -- the latter should be used.
  3. Reality.check! should say which services are configured, which are not and for what purposes they serve. Also note "demo-configured services"
  4. Better documentation for configuration process.

Data caching

Maybe should be done on Infoboxer's side. Just two general considerations:

  • when you call something like countries ten times a day, there's no point to query (rather huge) list of pages again and again;
  • when you call countries in a several monthes -- it's reasonable to refetch everything: even country list itself may have changed, not speaking about populations, leaders and so on.

Country lists

  1. All countries list: it seems, should be hardcoded into reality (extracted from Wikipedia with some script, updated on each errrr world situation update), and just grabbed as a list via infoboxer;
  2. (Later?) Some specialized country lists (see Wolfram, see Wikipedia categories, and so on), like:
    • G8/G20/UN/other alianses countries;
    • countries by continent
    • ...

Ruby syntaxt for 2 may be like:

# fetch-then-test syntax
Reality.countries.select(&:g20?)
Reality.countries.select{|c| c.continent.name == 'South America'}

# DB-alike query syntax
Reality.countries.where(continent: 'South America').all

Using Reality in other languages

Q: Can I use the reality gem with the German Wikipedia too? (@wintermeyer at Twitter)

A: It one of far targets, but it is not easy target. Reality currently extracts core data from (English) Wikipedia and Wikidata.

Wikidata is multilingual and uniformly so. Reality currently ignores this fact: there are hard-coded "en" here and there, but I feel like it should be easy to generalize the behavior.

With Wikipedia, things are harder. infoboxer gem, which we develop for structured access to Wikipedia, is targeted to be multi-lingual:

page = Infoboxer.wikipedia(:de).get('Deutschland')
# => #<Page(title: "Deutschland", url: "https://de.wikipedia.org/wiki/Deutschland")
puts page.paragraphs.first
# (Vollform: Bundesrepublik Deutschland) ist ein föderal verfasster Staat in Mitteleuropa....

But for access to most interesting data there is need for use Wikipedia templates, which are language-version dependent (defined by names). For example,

page.infobox
# => nil

...while visually we can see there's infobox on the page.

That's because there are separate template definitions for each wiki, and only for English wikipedia they are defined: https://github.com/molybdenum-99/infoboxer/blob/master/lib/infoboxer/definitions/en.wikipedia.org.rb

So, if you want to have Reality in your language, you'll need to start from grasping Wikipedia templates and defining most popular of them. Like this :-\

Extras: time at geographic point

Interface:

# minimal
Reality.city('Buenos-Aires').current_time # => 2016-01-11 06:38:51 -0300

# more:
Reality.city('Buenos-Aires').time(2015, 1, 11, 6, 38) # => 2016-01-11 06:38:00 -0300
Reality.city('Buenos-Aires').time('2015-01-11 06:38')  # => 2016-01-11 06:38:00 -0300

# or, better (?) alternative:
Reality.city('Buenos-Aires').time.zone
Reality.city('Buenos-Aires').time.now
Reality.city('Buenos-Aires').time.local(2015, 1, 11, 6, 38)
Reality.city('Buenos-Aires').time.parse('2015-01-11 06:38')

Implementation:

  • case1: Entity has explicit time_zone field: use it;
  • case2: Entity has geographic coords, or place name: guess timezone (some methods -- maybe this gem should be ok, at least for the beginning)

Geo: enchance Coord class

Possible implementations: GeoKit.
Possible ideas:

  • coord.distance_to(coord)
  • coord.city (reverse geocoding)
  • coord.route_to(coord) (routing)
  • add more (look at Wolfram, please!)

Imporant consideration:

  • everything for "just calculations" (without usage of external APIs) can go straight into Coord class
  • everything with external API usage should go into separate (with possible opt-out in future) modules in extras/

Wikidata predicate flexibility

There's several useful things that could be done:

  • plural/singular: define that predicate creates both tld and tlds methods, with former returning just first values of latter. (many countries have more than one tld, but for typical demo code its "too much information")
  • aliases: Entity('Beatles').parts is a bit dumb, no?..
  • moar?..

WikiData: generic Entry

Part of transition to wikidata

  • entry can be loaded by Wikipedia article name or wikidata id;
  • entry is loaded via sparql endpoint (with conversion from predicates to wikidata properties/claims);
  • properties are extracted with their labels, and are accessible;
  • common properties (like "coordinate location": P625, or "date of birth" -- list TBD) is accessible as methods (only when property exists)
  • property values which are links to other wikidate entries should return instance of Entry

More inspection methods

...for country, city and general unit.
Maybe several different methods, use cases:

  • in list of countries, see which country is which (like just #<Reality::Country[Ukraine]>);
  • for concrete country, see which properties it have, and what can be done with them;
  • have data from above pretty looking in IRuby notebook;
  • when there's many properties, have them structured in some kind of "sections".

More docs

Necessary:

  • note on data quality;
  • note on contributing process (how to select new data type, what to extract, how to test);
  • more examples and use cases.

Country datasets

Interface:

countries.where(
  population_gt: 20_000, 
  population_lt: 50_000, 
  continent: "Africa", 
  languages: ["Spanish"])...

Implementations: with multiple "List of countries by ...." pages, extract navigational data, filter links to countries by this data.

Country + city

  • Country#capital -- instance of a City (maybe not loaded at once, some proxy/Reality::Link object);
  • Country#cities -- some queriable "dataset" (NOT the list of all cities we know something about!); made via "List of cities in %countryname%" articles.

undefined method 'config' for reality

when I forked the repo and run rspec ., it throws undefined method for reality module with the following trace

/home/gaurav/code/reality/spec/spec_helper.rb:17:in `<top (required)>': undefined method `configure' for Reality:Module (NoMethodError)
	from /home/gaurav/.rvm/gems/ruby-2.3.4/gems/rspec-core-3.7.1/lib/rspec/core/configuration.rb:1455:in `require'
	from /home/gaurav/.rvm/gems/ruby-2.3.4/gems/rspec-core-3.7.1/lib/rspec/core/configuration.rb:1455:in `block in requires='
	from /home/gaurav/.rvm/gems/ruby-2.3.4/gems/rspec-core-3.7.1/lib/rspec/core/configuration.rb:1455:in `each'
	from /home/gaurav/.rvm/gems/ruby-2.3.4/gems/rspec-core-3.7.1/lib/rspec/core/configuration.rb:1455:in `requires='
	from /home/gaurav/.rvm/gems/ruby-2.3.4/gems/rspec-core-3.7.1/lib/rspec/core/configuration_options.rb:112:in `block in process_options_into'
	from /home/gaurav/.rvm/gems/ruby-2.3.4/gems/rspec-core-3.7.1/lib/rspec/core/configuration_options.rb:111:in `each'
	from /home/gaurav/.rvm/gems/ruby-2.3.4/gems/rspec-core-3.7.1/lib/rspec/core/configuration_options.rb:111:in `process_options_into'
	from /home/gaurav/.rvm/gems/ruby-2.3.4/gems/rspec-core-3.7.1/lib/rspec/core/configuration_options.rb:21:in `configure'
	from /home/gaurav/.rvm/gems/ruby-2.3.4/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:99:in `setup'
	from /home/gaurav/.rvm/gems/ruby-2.3.4/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:86:in `run'
	from /home/gaurav/.rvm/gems/ruby-2.3.4/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:71:in `run'
	from /home/gaurav/.rvm/gems/ruby-2.3.4/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:45:in `invoke'
	from /home/gaurav/.rvm/gems/ruby-2.3.4/gems/rspec-core-3.7.1/exe/rspec:4:in `<top (required)>'
	from /home/gaurav/.rvm/gems/ruby-2.3.4/bin/rspec:23:in `load'
	from /home/gaurav/.rvm/gems/ruby-2.3.4/bin/rspec:23:in `<main>'
	from /home/gaurav/.rvm/gems/ruby-2.3.4/bin/ruby_executable_hooks:15:in `eval'
	from /home/gaurav/.rvm/gems/ruby-2.3.4/bin/ruby_executable_hooks:15:in `<main>'

Design: list of "knowledge types" to implement

Potential list of data (like cities and countries) to take in account.
Possible consideration:

  • "common knowledge" (geography, biology, planets)
  • "actual" (currency rates, weather, sunrises and sunsets)
  • "interesting" (movies, music groups, space sattelites)
  • easy to extract from open APIs
  • looking cool in demos
  • useful for teaching and showcasing Ruby
  • not included in this list

Good list to start from is Wolfram's list of scopes: http://reference.wolfram.com/language/

Measure: conversions

Look at https://github.com/joshwlewis/unitwise for list of useful measures and conversions (or incoroporate Unitwise).
Requirements include:

  • direct synonyms: Measure(1, 'km') + Measure(2, 'kilometers');
  • scaled measures: Measure(1, 'km') + Measure(20, 'm');
  • different measures of same quantity: Measure(1, 'm') - Measure(1, 'ft');
  • physical simplifications: kg*m/s²N.

Integration with wit.ai

Hi, awesome project! I would love to see this grow to wolfram alpha's scale.

I think it would be very nice and useful to integrate this with wit.ai in order to understand natural language.

Great job!

For Measure the gem Unitwise could be very efficient.

See https://github.com/joshwlewis/unitwise

Here some examples:

require 'unitwise'

distance = Unitwise(0.25, 'mile')   # => #<Unitwise::Measurement value=0.25 unit=mile>
time     = Unitwise(10,   'second') # => #<Unitwise::Measurement value=10 unit=second>
mass     = Unitwise(2800, 'pound')  # => #<Unitwise::Measurement value=2800 unit=pound>

acceleration = 2.0 * distance / time ** 2
# => #<Unitwise::Measurement value=0.005 unit=[mi_us]/s2>

force = (mass * acceleration).to_lbf
# => #<Unitwise::Measurement value=2297.5084316991147 unit=lbf>

power = (force * distance / time).to_horsepower
# => #<Unitwise::Measurement value=551.4031264140402 unit=horsepower>

speed = ((2.0 * acceleration * distance) ** 0.5).convert_to("mile/hour")
# => #<Unitwise::Measurement value=180.0 unit=mile/hour>

Unitwise(20, 'milligram') / Unitwise(1, 'liter')
# => #<Unitwise::Measurement value=20 unit=mg/l>

Extras: OpenStreetMap

This is a huge project, which could be VERY helpful.
Parts include:

  • Reality-aware reverse geocoding: Geo::Coord.new(..., ...).address having City, Country and other parts as a Reality::Entity;
  • Reality-aware routing: E('Kharkiv').route_to('Kyiv', :auto)
    • ...with all intermediate objects being entities, allowing to do things like E('Kharkiv').route_to('Kyiv', :auto).map(&:city).map(&:population);
  • Reality-aware search: E('Times Square').venues(:restaurant) (returning list of Reality::Entitiy also);
  • Lists: E('Ukraine').roads.length.

Also clarification will be needed about entities which can be found ONLY on OSM, not Wikipedia/Wikidata.

Some thoughts on implementation:

  • Wikidata has predicate "OSM relation" for many items;
  • OSM has tag "wikipedia link" or something like that for relations.

Entity#to_h

Should be JSON-able, so return only simple types (strings, numbers, arrays, hashes and so on).
Thing to consider:

  • if country.capital is not loaded, it renders to hash as capital: "Buenos Aires";
  • ...but if it is loaded, renders as capital: capital.to_h

(Is it sane?..)

Extras: OpenStreetMap -- make some plan

What should/can be done here: evaluate OSM API and propose some reasonable API.
It should go into Coord data type.

Some examples, which may or may not look reasonable:

city('Kharkiv').distance_to(city('Kyiv'))
city('Kharkiv').path_to(city('Kyiv'), transport: :auto)

# more complicated task:
Geo::Coord(..., ...).country 
# => should try its best to return inctance of Reality::Country
# same for City

# future super-features like:
city('Kharkiv').path_to(city('Kyiv'), transport: :auto).cities 
# => array of Reality::City the path goes throuhg

# what more?..

Indication for long-working tasks

For example, Reality.countries works like 55 seconds on my laptop. Should say something like "please wait" at least, show progress-bar at best :)

Plan for next entity types

There's already some work (in data/infobox*.txt). Most interesting infoboxes type should be selected and planned to implement after 0.1.0

Ruby version issues

I've tried using this with ruby 1.9.3-p327, and ruby 2.0.0-p247 to no avail. It seems to work beautifully for ruby 2.1.2 and up.

Trying to run the first sample page results in the following error:

/Users/drthunder/.rvm/gems/ruby-1.9.3-p327/gems/mediawiktory-0.0.2/lib/mediawiktory.rb:7:in `require_relative': /Users/drthunder/.rvm/gems/ruby-1.9.3-p327/gems/mediawiktory-0.0.2/lib/mediawiktory/client.rb:21: syntax error, unexpected tPOW (SyntaxError)
def initialize(url, **options)

I recognize that the issue here is with mediawikitory, but since you're also responsible for mediawikitory and I'm encountering it by way of using the reality gem i thought I'd submit the issue here to give a greater context. The gem page says no minimum ruby version, but it seems like there might be some issues with older versions.

Thoughts?

IRuby Notebook integration

There should be isolated (not required by default) lib/reality/iruby module, which, on require adds #to_html method to Entity and List, making them pretty for IRuby Notebook. And maybe Entity#describe should return some object, which is inspect-ed as a multiline string (for irb) and to_html-ed as, well, pretty HTML?..

City concept

Test cases:

Reality.city('Dallas') # => should be Reality::City
Reality.city('Nothing') # => should be nil
Reality.city('New York') # => what should it be? In wikipedia, "New York" is state, and "New York City" is a city...
Reality.city('Odessa') # => city in Ukraine, but how to extract all other Odessas? https://en.wikipedia.org/wiki/Odessa_(disambiguation)

The requirements are the roughly same as for country (#1), plus city.country should return Country object, of course.

Docs: write "Proposed Tutorial"

For making reasonable and consistent plans, I'd try to write "preliminary" Tutorial document (from point-of-view "imagine Reality already exists and released to wide public"). Assumption is: only what goes well and reasonable into tutorial should go in General Plan.

Named measures

Measurement units, using countries as example: population returns Reality::Measure[123400 people], which is inspectable and convertible, but checks unit on operations.

Cleanup about method inclusion

In console, we have Reality::Methods included, but not Reality itself (so, Entity('Blah') works, but Entity.new('Blah') is NOT).
In README's recommendations, the same ambiguity could be seen. Bad.

Undefined method 'Entity' for main object

Trying to have a play around with the gem but keep running into this error. Currently:

$ require 'reality'
$ include Reality

$ Entity
$ # => Reality::Entity

$ Entity('Australia')
$ # => Undefined method 'Entity' for main:Object

$ Reality::Entity('Australia')
$ # => #<Reality::Entity(Australia):country>

Interest in a CLI

Is there any interest in a CLI for this? I made a quick script to expose the describe method, but if anyone else would find this useful I wouldn't mind contributing it.

This is an awesome gem by the way 😄

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.