Skip to content

Instantly share code, notes, and snippets.

@basicxman
Created May 27, 2011 23:31
Show Gist options
  • Select an option

  • Save basicxman/996399 to your computer and use it in GitHub Desktop.

Select an option

Save basicxman/996399 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Extended Mind
# Now I want to graph the data, luckily we can just use the YAML cache as a data source.
require 'yaml'
require 'ap'
class Graph
attr_accessor :graph
def initialize
data = {}
file_data = YAML.load_file("./mind_cur.cache")
file_data.each do |parent, child|
data[unwikify(parent)] = unwikify(child)
end
@global_store = {}
data.each do |parent, child|
@global_store[child] ||= []
@global_store[child] << parent
end
ap @global_store
@graph = {}
@graph["Philosophy"] = resolve("Philosophy")
end
def resolve(root)
puts "Resolving #{root}"
temp = {}
@global_store[root].each do |key|
if @global_store[key].nil?
temp[key] = :done
else
temp[key] = resolve(key)
end
end
temp
end
def unwikify(text)
temp = text.dup
temp.gsub! "http://wikipedia.org", ""
temp.gsub! "/wiki/", ""
temp
end
end
g = Graph.new
ap g.graph
@basicxman

Copy link
Copy Markdown
Author

Bah! Mah stack, it's not big enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment