Browse files

initial commit

  • Loading branch information...
0 parents commit a5ec0f28315f988e5d7de9381d5e5453298141ff Mark Burns committed Mar 29, 2010
Showing with 504,300 additions and 0 deletions.
  1. +243 −0 README
  2. +10 −0 Rakefile
  3. +10 −0 app/controllers/application_controller.rb
  4. +3 −0 app/helpers/application_helper.rb
  5. +4 −0 app/models/dictionary.rb
  6. +2 −0 app/models/edict_mapping.rb
  7. +2 −0 app/models/english_word.rb
  8. +17 −0 app/models/heisig.rb
  9. +8 −0 app/models/heisig_keyword.rb
  10. +2 −0 app/models/japanese_word.rb
  11. +3 −0 app/models/jlpts_kanji.rb
  12. +3 −0 app/models/joyos_kanji.rb
  13. +265 −0 app/models/kanji.rb
  14. +4 −0 app/models/kanji_lookup.rb
  15. +448 −0 app/models/kanjidic_importer.rb
  16. +4 −0 app/models/korean.rb
  17. +4 −0 app/models/koreans_kanji.rb
  18. +14 −0 app/models/kunyomi.rb
  19. +4 −0 app/models/kunyomi_readings.rb
  20. +8 −0 app/models/kunyomis_kanji.rb
  21. +3 −0 app/models/kyuujitai.rb
  22. +2 −0 app/models/language.rb
  23. +4 −0 app/models/meanings_kanji.rb
  24. +4 −0 app/models/nanori.rb
  25. +4 −0 app/models/nanoris_kanji.rb
  26. +8 −0 app/models/onyomi.rb
  27. +4 −0 app/models/onyomi_readings.rb
  28. +7 −0 app/models/onyomis_kanji.rb
  29. +4 −0 app/models/pinyin.rb
  30. +4 −0 app/models/pinyins_kanji.rb
  31. +16 −0 app/models/primitive.rb
  32. +5 −0 app/models/primitives_kanji.rb
  33. +4 −0 app/models/skip.rb
  34. +4 −0 app/models/skips_kanji.rb
  35. +2 −0 app/models/tanaka_english_word.rb
  36. +2 −0 app/models/tanaka_japanese_word.rb
  37. +2 −0 app/models/tanaka_sentence.rb
  38. +110 −0 config/boot.rb
  39. +7 −0 config/cucumber.yml
  40. +54 −0 config/environment.rb
  41. +27 −0 config/environments/cucumber.rb
  42. +17 −0 config/environments/development.rb
  43. +28 −0 config/environments/production.rb
  44. +30 −0 config/environments/test.rb
  45. +7 −0 config/initializers/backtrace_silencers.rb
  46. +10 −0 config/initializers/inflections.rb
  47. +5 −0 config/initializers/mime_types.rb
  48. +21 −0 config/initializers/new_rails_defaults.rb
  49. +15 −0 config/initializers/session_store.rb
  50. +5 −0 config/locales/en.yml
  51. +43 −0 config/routes.rb
  52. +24 −0 connection.rb
  53. BIN db/development.sqlite3
  54. +175,499 −0 db/edict
  55. +2,116 −0 db/jlpt.csv
  56. +1,946 −0 db/joyo.csv
  57. +6,356 −0 db/kanjidic
  58. +6,355 −0 db/kradfile
  59. +397 −0 db/migrate/20100329165705_initial_migration.rb
  60. +285 −0 db/schema.rb
  61. +7 −0 db/seeds.rb
  62. +300,852 −0 db/tanaka
  63. +2 −0 doc/README_FOR_APP
  64. +273 −0 features/step_definitions/web_steps.rb
  65. +57 −0 features/support/env.rb
  66. +27 −0 features/support/paths.rb
  67. +47 −0 lib/tasks/cucumber.rake
  68. +144 −0 lib/tasks/rspec.rake
  69. +279 −0 log/development.log
  70. 0 log/production.log
  71. 0 log/server.log
  72. 0 log/test.log
  73. +30 −0 public/404.html
  74. +30 −0 public/422.html
  75. +30 −0 public/500.html
  76. 0 public/favicon.ico
  77. BIN public/images/rails.png
  78. +275 −0 public/index.html
  79. +2 −0 public/javascripts/application.js
  80. +963 −0 public/javascripts/controls.js
  81. +973 −0 public/javascripts/dragdrop.js
  82. +1,128 −0 public/javascripts/effects.js
  83. +4,320 −0 public/javascripts/prototype.js
  84. +5 −0 public/robots.txt
  85. +4 −0 script/about
  86. +6 −0 script/autospec
  87. +3 −0 script/console
  88. +10 −0 script/cucumber
  89. +3 −0 script/dbconsole
  90. +3 −0 script/destroy
  91. +3 −0 script/generate
  92. +3 −0 script/performance/benchmarker
  93. +3 −0 script/performance/profiler
  94. +3 −0 script/plugin
  95. +3 −0 script/runner
  96. +3 −0 script/server
  97. +10 −0 script/spec
  98. +198 −0 spec/kanjidic_importer_spec.rb
  99. +2 −0 spec/rcov.opts
  100. +4 −0 spec/spec.opts
  101. +54 −0 spec/spec_helper.rb
  102. +9 −0 test/performance/browsing_test.rb
  103. +38 −0 test/test_helper.rb
243 README
@@ -0,0 +1,243 @@
+== Welcome to Rails
+
+Rails is a web-application framework that includes everything needed to create
+database-backed web applications according to the Model-View-Control pattern.
+
+This pattern splits the view (also called the presentation) into "dumb" templates
+that are primarily responsible for inserting pre-built data in between HTML tags.
+The model contains the "smart" domain objects (such as Account, Product, Person,
+Post) that holds all the business logic and knows how to persist themselves to
+a database. The controller handles the incoming requests (such as Save New Account,
+Update Product, Show Post) by manipulating the model and directing data to the view.
+
+In Rails, the model is handled by what's called an object-relational mapping
+layer entitled Active Record. This layer allows you to present the data from
+database rows as objects and embellish these data objects with business logic
+methods. You can read more about Active Record in
+link:files/vendor/rails/activerecord/README.html.
+
+The controller and view are handled by the Action Pack, which handles both
+layers by its two parts: Action View and Action Controller. These two layers
+are bundled in a single package due to their heavy interdependence. This is
+unlike the relationship between the Active Record and Action Pack that is much
+more separate. Each of these packages can be used independently outside of
+Rails. You can read more about Action Pack in
+link:files/vendor/rails/actionpack/README.html.
+
+
+== Getting Started
+
+1. At the command prompt, start a new Rails application using the <tt>rails</tt> command
+ and your application name. Ex: rails myapp
+2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options)
+3. Go to http://localhost:3000/ and get "Welcome aboard: You're riding the Rails!"
+4. Follow the guidelines to start developing your application
+
+
+== Web Servers
+
+By default, Rails will try to use Mongrel if it's are installed when started with script/server, otherwise Rails will use WEBrick, the webserver that ships with Ruby. But you can also use Rails
+with a variety of other web servers.
+
+Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is
+suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
+getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
+More info at: http://mongrel.rubyforge.org
+
+Say other Ruby web servers like Thin and Ebb or regular web servers like Apache or LiteSpeed or
+Lighttpd or IIS. The Ruby web servers are run through Rack and the latter can either be setup to use
+FCGI or proxy to a pack of Mongrels/Thin/Ebb servers.
+
+== Apache .htaccess example for FCGI/CGI
+
+# General Apache options
+AddHandler fastcgi-script .fcgi
+AddHandler cgi-script .cgi
+Options +FollowSymLinks +ExecCGI
+
+# If you don't want Rails to look in certain directories,
+# use the following rewrite rules so that Apache won't rewrite certain requests
+#
+# Example:
+# RewriteCond %{REQUEST_URI} ^/notrails.*
+# RewriteRule .* - [L]
+
+# Redirect all requests not available on the filesystem to Rails
+# By default the cgi dispatcher is used which is very slow
+#
+# For better performance replace the dispatcher with the fastcgi one
+#
+# Example:
+# RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
+RewriteEngine On
+
+# If your Rails application is accessed via an Alias directive,
+# then you MUST also set the RewriteBase in this htaccess file.
+#
+# Example:
+# Alias /myrailsapp /path/to/myrailsapp/public
+# RewriteBase /myrailsapp
+
+RewriteRule ^$ index.html [QSA]
+RewriteRule ^([^.]+)$ $1.html [QSA]
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
+
+# In case Rails experiences terminal errors
+# Instead of displaying this message you can supply a file here which will be rendered instead
+#
+# Example:
+# ErrorDocument 500 /500.html
+
+ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
+
+
+== Debugging Rails
+
+Sometimes your application goes wrong. Fortunately there are a lot of tools that
+will help you debug it and get it back on the rails.
+
+First area to check is the application log files. Have "tail -f" commands running
+on the server.log and development.log. Rails will automatically display debugging
+and runtime information to these files. Debugging info will also be shown in the
+browser on requests from 127.0.0.1.
+
+You can also log your own messages directly into the log file from your code using
+the Ruby logger class from inside your controllers. Example:
+
+ class WeblogController < ActionController::Base
+ def destroy
+ @weblog = Weblog.find(params[:id])
+ @weblog.destroy
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
+ end
+ end
+
+The result will be a message in your log file along the lines of:
+
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1
+
+More information on how to use the logger is at http://www.ruby-doc.org/core/
+
+Also, Ruby documentation can be found at http://www.ruby-lang.org/ including:
+
+* The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
+* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
+
+These two online (and free) books will bring you up to speed on the Ruby language
+and also on programming in general.
+
+
+== Debugger
+
+Debugger support is available through the debugger command when you start your Mongrel or
+Webrick server with --debugger. This means that you can break out of execution at any point
+in the code, investigate and change the model, AND then resume execution!
+You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'
+Example:
+
+ class WeblogController < ActionController::Base
+ def index
+ @posts = Post.find(:all)
+ debugger
+ end
+ end
+
+So the controller will accept the action, run the first line, then present you
+with a IRB prompt in the server window. Here you can do things like:
+
+ >> @posts.inspect
+ => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
+ #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
+ >> @posts.first.title = "hello from a debugger"
+ => "hello from a debugger"
+
+...and even better is that you can examine how your runtime objects actually work:
+
+ >> f = @posts.first
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
+ >> f.
+ Display all 152 possibilities? (y or n)
+
+Finally, when you're ready to resume execution, you enter "cont"
+
+
+== Console
+
+You can interact with the domain model by starting the console through <tt>script/console</tt>.
+Here you'll have all parts of the application configured, just like it is when the
+application is running. You can inspect domain models, change values, and save to the
+database. Starting the script without arguments will launch it in the development environment.
+Passing an argument will specify a different environment, like <tt>script/console production</tt>.
+
+To reload your controllers and models after launching the console run <tt>reload!</tt>
+
+== dbconsole
+
+You can go to the command line of your database directly through <tt>script/dbconsole</tt>.
+You would be connected to the database with the credentials defined in database.yml.
+Starting the script without arguments will connect you to the development database. Passing an
+argument will connect you to a different database, like <tt>script/dbconsole production</tt>.
+Currently works for mysql, postgresql and sqlite.
+
+== Description of Contents
+
+app
+ Holds all the code that's specific to this particular application.
+
+app/controllers
+ Holds controllers that should be named like weblogs_controller.rb for
+ automated URL mapping. All controllers should descend from ApplicationController
+ which itself descends from ActionController::Base.
+
+app/models
+ Holds models that should be named like post.rb.
+ Most models will descend from ActiveRecord::Base.
+
+app/views
+ Holds the template files for the view that should be named like
+ weblogs/index.html.erb for the WeblogsController#index action. All views use eRuby
+ syntax.
+
+app/views/layouts
+ Holds the template files for layouts to be used with views. This models the common
+ header/footer method of wrapping views. In your views, define a layout using the
+ <tt>layout :default</tt> and create a file named default.html.erb. Inside default.html.erb,
+ call <% yield %> to render the view using this layout.
+
+app/helpers
+ Holds view helpers that should be named like weblogs_helper.rb. These are generated
+ for you automatically when using script/generate for controllers. Helpers can be used to
+ wrap functionality for your views into methods.
+
+config
+ Configuration files for the Rails environment, the routing map, the database, and other dependencies.
+
+db
+ Contains the database schema in schema.rb. db/migrate contains all
+ the sequence of Migrations for your schema.
+
+doc
+ This directory is where your application documentation will be stored when generated
+ using <tt>rake doc:app</tt>
+
+lib
+ Application specific libraries. Basically, any kind of custom code that doesn't
+ belong under controllers, models, or helpers. This directory is in the load path.
+
+public
+ The directory available for the web server. Contains subdirectories for images, stylesheets,
+ and javascripts. Also contains the dispatchers and the default HTML files. This should be
+ set as the DOCUMENT_ROOT of your web server.
+
+script
+ Helper scripts for automation and generation.
+
+test
+ Unit and functional tests along with fixtures. When using the script/generate scripts, template
+ test files will be generated for you and placed in this directory.
+
+vendor
+ External libraries that the application depends on. Also includes the plugins subdirectory.
+ If the app has frozen rails, those gems also go here, under vendor/rails/.
+ This directory is in the load path.
10 Rakefile
@@ -0,0 +1,10 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require(File.join(File.dirname(__FILE__), 'config', 'boot'))
+
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+require 'tasks/rails'
10 app/controllers/application_controller.rb
@@ -0,0 +1,10 @@
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class ApplicationController < ActionController::Base
+ helper :all # include all helpers, all the time
+ protect_from_forgery # See ActionController::RequestForgeryProtection for details
+
+ # Scrub sensitive parameters from your log
+ # filter_parameter_logging :password
+end
3 app/helpers/application_helper.rb
@@ -0,0 +1,3 @@
+# Methods added to this helper will be available to all templates in the application.
+module ApplicationHelper
+end
4 app/models/dictionary.rb
@@ -0,0 +1,4 @@
+class Dictionary < ActiveRecord::Base
+ has_many :kanji_lookups
+ has_many :kanjis, :through => :kanji_lookups
+end
2 app/models/edict_mapping.rb
@@ -0,0 +1,2 @@
+class EdictMapping < ActiveRecord::Base
+end
2 app/models/english_word.rb
@@ -0,0 +1,2 @@
+class EnglishWord < ActiveRecord::Base
+end
17 app/models/heisig.rb
@@ -0,0 +1,17 @@
+class Heisig < ActiveRecord::Base
+ belongs_to :kanji
+ has_many :heisig_keywords, :dependent => :destroy
+
+ def heisig_keyword
+ heisig_keywords[0]
+ end
+
+ def keyword
+ unless heisig_keywords[0].nil?
+ return heisig_keywords[0].keyword
+ end
+ return ""
+ end
+
+
+end
8 app/models/heisig_keyword.rb
@@ -0,0 +1,8 @@
+class HeisigKeyword < ActiveRecord::Base
+ belongs_to :heisig
+ has_one :heisig_edition
+ has_one :language
+ def kanji
+ return heisig.kanji unless heisig.nil?
+ end
+end
2 app/models/japanese_word.rb
@@ -0,0 +1,2 @@
+class JapaneseWord < ActiveRecord::Base
+end
3 app/models/jlpts_kanji.rb
@@ -0,0 +1,3 @@
+class JlptsKanji < ActiveRecord::Base
+ belongs_to :kanji
+end
3 app/models/joyos_kanji.rb
@@ -0,0 +1,3 @@
+class JoyosKanji < ActiveRecord::Base
+ belongs_to :kanji
+end
265 app/models/kanji.rb
@@ -0,0 +1,265 @@
+class Kanji < ActiveRecord::Base
+
+ cattr_reader :per_page
+ @@per_page = 100
+
+ has_one :studyable_item, :as => :studyable
+ ARBITRARY_LARGE_NUMBER_OF_KANJI = 100000
+ has_one :heisig
+ has_many :heisig_keywords, :through => :heisig
+ has_many :primitives_kanjis
+ has_many :primitives, :through => :primitives_kanjis
+ has_many :onyomis_kanjis
+ has_many :onyomis, :through => :onyomis_kanjis
+ has_many :kunyomis_kanjis
+ has_many :kunyomis, :through => :kunyomis_kanjis
+ has_many :pinyins_kanjis
+ has_many :pinyins, :through => :pinyins_kanjis
+ has_many :koreans_kanjis
+ has_many :koreans, :through => :koreans_kanjis
+ has_many :meanings_kanjis
+ has_many :meanings, :through => :meanings_kanjis
+ has_many :stories, :as => :commentable
+ has_many :kanji_tree_edits
+ has_many :jlpts_kanjis
+ has_many :joyos_kanjis
+ has_one :skips_kanji
+ has_one :skip, :through => :skips_kanji
+
+ has_many :kyuujitai
+
+ def to_s
+ kanji
+ end
+
+ def kanji
+ read_attribute(:kanji)#.force_encoding 'utf-8'
+ end
+
+
+
+ named_filter :heisig do |min, max|
+ having :heisig_keywords do
+ with(:heisig_id).between(min.to_i,max.to_i)
+ end
+ group_by 'kanjis.id'
+ end
+
+
+ named_filter(:joyo) do |levels|
+ having(:joyos_kanjis) do
+ any_of do
+ if levels.class==Array
+ levels.each do |level|
+ with(:level).equal_to level
+ end
+ elsif levels.class == Fixnum
+ with(:level).equal_to levels
+ end
+ end
+ end
+ group_by 'kanjis.id'
+ end
+
+ named_filter(:jlpt) do |levels|
+ having(:jlpts_kanjis) do
+ any_of do
+ if levels.class == Array
+ levels.each do |level|
+ with(:level).equal_to level
+ end
+ elsif levels.class == Fixnum
+ with(:level).equal_to levels
+ end
+ end
+ end
+ group_by 'kanjis.id'
+ end
+
+
+ named_filter(:cumulative_frequency_range) do |min,max|
+ with(:cumulative_frequency).gte min.to_f
+ with(:cumulative_frequency).lte max.to_f
+ end
+
+ #Helper method maps params found in hash
+ #to their corresponding expected values
+ #wherever a parameter has a value of '1' then
+ #the expected value is added to the return array
+ #For example:
+ #
+ def self.hash_params_to_a hash, params
+ #If all values are set to 0 then don't get Joyo Kanji
+ zero_count=0
+ levels = []
+ #build array of levels to send to named_scope
+ hash.each_pair do |key,value|
+ if params[key]=="1"
+ levels << value
+ elsif params[key]=="0"
+ zero_count+=1
+ end
+ end
+
+ #If all values are set to 0 then don't get Joyo Kanji
+ if zero_count == hash.length
+ levels = []
+ end
+ return levels
+ end
+
+
+ named_filter :with_onyomis do
+ having(:onyomis_kanjis) do
+ having(:onyomi)
+ end
+ end
+
+ named_filter :include_onyomis do
+ join(OnyomisKanji, :join_type => :left) do
+ on :id=>:kanji_id
+ join(Onyomi) do
+ on :onyomi_id=>:id
+ end
+ end
+ end
+
+
+ def self.find_filtered params, options
+ page = options[:page]
+ per_page = options[:per_page]
+ chain = Kanji
+
+ #chain = chain.all(:include => [:onyomis, :kunyomis, :meanings, :heisig, :heisig_keywords])
+
+ #filter name, start value and end value (min max)
+ filters = [[:heisig,:heisig_start, :heisig_end],
+ [:heisig_lesson,:heisig_lesson_start,:heisig_lesson_end],
+ [:cumulative_frequency_range, :frequency_start, :frequency_end]
+ ]
+
+ filters.each do |filter|
+
+ filter_name = filter[0]
+ min = params[filter[1].to_s]
+ max = params[filter[2].to_s]
+ #if we have values for each parameter
+ if min && max
+ #process the filter
+ chain = chain.send(filter_name,min,max)
+
+ end
+ end
+ #go over each selection and append to filter chain
+ selections = [
+ [:joyo, {:joyo_1 => '1', :joyo_2 => '2', :joyo_3 => '3',
+ :joyo_4 => '4',:joyo_5 =>'5',:joyo_6 =>'6', :joyo_high_school =>'S'}],
+ [:jlpt, {:jlpt_1 => '1', :jlpt_2 => '2', :jlpt_3 => '3',
+ :jlpt_4 => '4',
+ :jlpt_n1 => 'N1', :jlpt_n2 => 'N2', :jlpt_n3 => 'N3',
+ :jlpt_n4 => 'N4', :jlpt_n5 => 'N5'}]
+ ]
+
+ selections.each do |selection|
+ method = selection[0]
+ hash = selection[1]
+ levels = self.hash_params_to_a(hash,params)
+ if levels.length > 0
+ chain = chain.send(method, levels)
+ end
+ end
+
+
+ sum = chain.sum(:frequency_percentage)
+ sum = (([sum, 100].min*100).round/ 100).to_s
+
+ count = chain.count.to_s #force the calculation before the pagination
+
+
+ chain = chain.paginate :page => page, :per_page => per_page
+
+ return include_readings(chain), count, sum
+ end
+
+
+ def self.include_readings collection
+ kanjis_collection = collection.to_a
+ puts kanjis_collection.class
+ kanji_ids = kanjis_collection.collect { |k| k.id}
+ readings=Kanji.find_all_by_id(kanji_ids, :include => :onyomis_kanjis).to_a
+
+ onyomis_kanji_ids = readings.collect {|k|
+ k.onyomis_kanjis.collect {|ok|
+ ok.onyomi_id
+ }.flatten
+ }.flatten
+
+ onyomis_kanjis = OnyomisKanji.find_all_by_id(onyomis_kanjis_ids, :include =>:onyomi)
+
+ end
+
+ def heisig_id
+ unless heisig.nil?
+ return heisig.id
+ end
+ end
+
+ def keyword
+ unless heisig.nil?
+ return heisig.keyword
+ end
+ return ""
+ end
+
+
+ def self.find_by_keyword keyword
+ h = HeisigKeyword.find_by_keyword keyword
+ return nil if h == nil
+ kanji_id = (Heisig.find(h.heisig_id)).kanji_id
+ Kanji.find kanji_id
+ end
+
+=begin
+
+1. when a user requests a kanji_tree_edit, a kanji is found which
+ EITHER "has no edits" (status "U" unedited, edit count 0)
+ OR "only has edit status of R (rejected)"
+
+ {i.e. NOT any of
+ P (pending submission awaiting opinion of admin),
+ OR H (held awaiting edit from user),
+ OR A (Accepted)
+ }
+
+ {optionally} AND satisfies the criteria requested by the user
+ (e.g. Heisig > x, JlptKanji.level == 4)
+=end
+
+ named_filter :unedited do
+ any_of do
+ having(:status).equal_to 'U'
+ having(:status).equal_to 'R'
+ end
+ end
+ named_filter :accepted do
+ having(:status).equal_to 'A'
+ end
+
+ named_filter(:rtk_lite) do
+ having :heisig do
+ with(:rtk_lite).equals true
+ order :heisig_id
+ end
+ end
+
+ named_filter (:frequency_range) do |min,max|
+ with(:cumulative_frequency).gte min.to_f
+ with(:cumulative_frequency).lte max.to_f
+ end
+
+ named_filter (:frequency_order) do
+ order :rank
+ end
+
+
+end
4 app/models/kanji_lookup.rb
@@ -0,0 +1,4 @@
+class KanjiLookup < ActiveRecord::Base
+ belongs_to :kanji
+ belongs_to :dictionary
+end
448 app/models/kanjidic_importer.rb
@@ -0,0 +1,448 @@
+#!/usr/bin/ruby
+# encoding: utf-8
+
+require 'pp'
+require 'connection'
+require 'hash_extension'
+
+class KanjidicImporter
+
+ attr_accessor :dictionary_lookup, :kanji_lookup, :onyomi_lookup
+ attr_reader :lookup_attributes
+ KANJIDIC = "../data/kanjidic"
+ ENGLISH = 1
+
+
+ def initialize
+ @lookup_attributes = [:kunyomi, :onyomi, :english_word, :nanori, :skip, :korean, :pinyin]
+ @index_names=[ :radical, :classical_radical, :halpern, :nelson,
+ :new_nelson, :japanese_for_busy_people, :kanji_way ,
+ :japanese_flashcards , :kodansha , :hensall , :kanji_in_context ,
+ :kanji_learners_dictionary , :french_heisig , :o_neill , :de_roo ,
+ :sakade , :tuttle_flash_card , :tuttle_dictionary ,
+ :tuttle_kanji_and_kana , :unicode, :four_corner ,
+ :heisig, :morohashi_index , :morohashi_volume_page ,
+ :henshall , :gakken , :japanese_names , :cross_reference ,
+ :misclassification]
+ generate_lookups()
+ end
+
+ def generate_lookups
+ @onyomi_lookup = table_to_hash_lookup Onyomi, "onyomi"
+ @kunyomi_lookup = table_to_hash_lookup Kunyomi, "kunyomi"
+ @nanori_lookup = table_to_hash_lookup Nanori, "nanori"
+ @english_word_lookup = table_to_hash_lookup EnglishWord, "english_word"
+ @kanji_lookup = table_to_hash_lookup Kanji, "kanji"
+ @korean_lookup = table_to_hash_lookup Korean, "korean"
+ @pinyin_lookup = table_to_hash_lookup Pinyin, "pinyin"
+
+ @skip_lookup = table_to_hash_lookup Skip, "skip_pattern"
+ use_symbol= true
+ @dictionary_lookup = table_to_hash_lookup Dictionary, "name", use_symbol
+ end
+
+ #creates an inverse lookup hash of column value to id
+ #obviously this needs unique values or the lookup is
+ #unpredictable
+ #key_column is the attribute in the table to use as the hash key
+ #value_column defaults to id, and is the attribute to use as the hash value
+ #string_key? is used to determine if the output hash has a string or symbol lookup
+ def table_to_hash_lookup table, key_column, symbol_key = false, value_column="id"
+ key_column = key_column.to_s #allows for accepting symbols or strings
+ value_column = value_column.to_s
+ o=table.find_as_hashes(:all, :select => "#{key_column}, #{value_column}")
+ #returns array of form
+ # [{"id"=>"1", "column"=>"value"},{"id" => "2", "column" => "value2"}....]
+
+ #convert to form
+ #{'value' => 1, 'value2' => 2,...}
+
+ dictionary=o.inject({}) {|result, element|
+ #only get values that have a key column
+
+ unless element[key_column].nil?
+ entry = element[key_column].to_s#.force_encoding("utf-8")
+ entry = entry.to_sym if symbol_key
+ #insert into the hash
+ result[entry] = element[value_column].to_i
+ end
+ result
+ }
+
+ return dictionary
+ end
+
+
+ #this imports the values that need importing before
+ #the whole file is parsed
+ #for example it imports the kunyomi readings so they
+ #can be used in the table KunyomisKanji
+ #I.e. it is necessary to do a pass over the file first, and
+ #populated the necessary tables with unique values, and
+ #then when going over each line the ids for the relationships
+ #are known
+ #validate -- run ActiveRecord validation
+ #delete -- delete all the records in each table first (to perfrom a complete
+ #datbase rebuild)
+ def import_reading_lookup_values lines, types=@lookup_attributes, validate=false, delete_all=true
+ ActiveRecord::Base.transaction do |transaction|
+ #returns a hash of arrays of values
+ unique_values = get_unique_values types, lines
+ unique_values.each_pair do |column,values|
+ table = eval(column.to_s.capitalize)
+ table.delete_all if delete_all
+ #make assumption name that e.g. kunyomi is column
+ #Kunyomi is model, with exception of skip_pattern
+ if column == :skip
+ column = :skip_pattern
+ end
+ #convert values array to 2D array for ar-extensions import
+ values2d =[]
+ values.each do |v|values2d<<[v];end
+ table.import [column],values2d, :validate=>validate
+ end
+ end
+
+ generate_lookups()
+ end
+
+ #imports all the various dictionary indexes found in the kanjidic file
+ def import_indexes indexes, validate=false, delete_all=true
+ columns = [:kanji_id, :dictionary_id, :dictionary_index_value]
+ ActiveRecord::Base.transaction do |transaction|
+ #puts "indexes:#{indexes}"
+ KanjiLookup.delete_all if delete_all
+ KanjiLookup.import columns, indexes, :validate =>validate
+ end
+ end
+
+ #imports the various relations e.g. KunyomisKanji, OnyomisKanji etc
+ #relationships - a hash of arrays of index values
+ #the hash key is the column name (symbol)
+ #the infered relationship is from e.g. :kunyomi -> KunomisKanji
+ def import_relationships relationships, validate=false, delete_all=true
+ ActiveRecord::Base.transaction do |transaction|
+ relationships.each_pair do |column, values|
+ table = eval(column.to_s.capitalize+"sKanji")
+ relation_id = (column.to_s + "_id").to_sym
+ columns = [:kanji_id, relation_id]
+ table.delete_all if delete_all
+ table.import columns, values, :validate => validate
+ end
+ end
+ end
+
+
+ #type - an array of Symbols or a single Symbol representing
+ #the dictionary name
+ #line - the line of data to parse
+ #appends to indexes
+ #[[kanji_id, dictionary_id, dictionary_index_value],[kanji_id,...],...]
+ def get_dictionary_index types, line, indexes=nil
+ indexes ||= []
+ if types.is_a? Symbol
+ types = [types]
+ end
+ kanji_id = @kanji_lookup[line[0]]
+ out=[]
+ types.each do |type|
+ dictionary_index_value = get_element(type, line)
+ unless dictionary_index_value.nil?
+ dictionary_id = @dictionary_lookup[type]
+ values = [kanji_id, dictionary_id, dictionary_index_value]
+ #puts "values:#{values}"
+ indexes << values
+ else
+ #puts "#{type} not found on this line"
+ end
+ end
+ return indexes
+ end
+
+ #returns a specific element from the line
+ #this function is tied to the kanjidic text format, which is unlikely
+ #to change fundamentally except add on extra indexes
+ def get_element type, line
+ case type
+ when :kanji
+ return line[0]
+ when :nanori, :onyomi, :kunyomi
+ nanori_match = regexp(:nanori_divider).match line
+ #if there is a nanori section then create the
+ # nanoris and get section for other readings (yomi)
+ unless nanori_match.nil?
+ nanori_section = nanori_match.post_match
+ nanoris = nanori_section.scan regexp(:kana)
+ yomi = nanori_match.pre_match
+ else #no nanoris everything is a yomi (normal reading)
+ nanoris= []
+ yomi = line
+ end
+ return nanoris if type == :nanori
+ #puts "processing #{type}"
+ return yomi.scan(regexp(type)).flatten
+
+ when :yomi, :english_word, :kana, :korean, :pinyin, :skip
+ return line.scan(regexp(type)).flatten
+
+ when :bushu, :radical, :historical_radical, :classical_radical, :halpern, :nelson,
+ :new_nelson, :japanese_for_busy_people, :kanji_way ,
+ :japanese_flashcards , :kodansha , :hensall , :kanji_in_context ,
+ :kanji_learners_dictionary , :french_heisig , :o_neill , :de_roo ,
+ :sakade , :tuttle_flash_card , :tuttle_dictionary ,
+ :tuttle_kanji_and_kana , :unicode, :four_corner ,
+ :heisig, :morohashi_index , :morohashi_volume_page ,
+ :henshall , :gakken , :japanese_names , :cross_reference ,
+ :misclassification
+ return (line.scan regexp(type)).flatten[0]
+
+ end
+ end
+
+ def regexp type
+ case type
+
+ when :katakana , :onyomi
+ /\b[ア-ン]+[ア-ン.]*\b/
+ when :hiragana , :kunyomi
+ #hiragana is the range of characters from あ-ん
+ /\b[あ-ん]+[あ-ん.]*\b/
+ when :kana
+ #kana is the sum of all the characters in hiragana and katakana
+ /\b[ア-ンあ-ん]+[ア-ンあ-ん.]*\b/
+ when :nanori_divider
+ /\sT1\s/
+ when :english_word
+ /\{([^\}]+)\}/ #anything between {}
+ when :korean
+ /\sW(\w+)\s/
+ when :pinyin
+ /\sY(\w+)\s/
+ when :stroke_count, :strokes #"Stroke count"
+ /\s(S[^\s]+)\s/
+ when :skip
+ /\sP([\d-]+)\s/
+ when :joyo
+ /\s(G[1-6])\s/
+ when :joyo_high_school
+ /\s(G[8])\s/
+ when :jinmeiyou
+ /\s(G[9])\s/
+ when :jinmeiyou_variant
+ /\s(G[10])\s/
+ when :jlpt
+ /\s(J([^\s]+))\s/
+ when :frequency
+ /\s(F[^\s]+)\s/
+ #indexes
+ when :radical, :bushu
+ /\sB([^\s]+)\s/
+ when :classical_radical, :historical_radical
+ /\bC([^\s]+)\b/
+ when :halpern
+ /\s(H[^\s]+)\s/
+ when :nelson
+ /\s(N[^\s]+)\s/
+ when :new_nelson
+ /\s(V[^\s]+)\s/
+ when :japanese_for_busy_people
+ /\s(DB[^\s]+)\s/
+ when :kanji_way #"The Kanji Way to Japanese Language Power";
+ /\s(DC[^\s]+)\s/
+ when :japanese_flashcards #"Japanese Kanji Flashcards";
+ /\s(DF[^\s]+)\s/
+ when :kodansha #"Kodansha Compact Kanji Guide";
+ /\s(DG[^\s]+)\s/
+ when :hensall #"A Guide To Reading and Writing Japanese";
+ /\s(DH[^\s]+)\s/
+ when :kanji_in_context #"Kanji in Context";
+ /\s(DJ[^\s]+)\s/
+ when :kanji_learners_dictionary #"Kanji Learners Dictionary";
+ /\s(DK[^\s]+)s/
+ when :french_heisig #"French adapatation of Heisig's Remembering The Kanji";
+ /\s(DM[^\s]+)\s/
+ when :o_neill #"O'Neill's Essential Kanji";
+ /\s(DO[^\s]+)\s/
+ when :de_roo #two_thousand_and_one_kanji #"2001 Kanji"
+ /\s(DR[^\s]+)\s/
+ when :sakade #"A Guide To Reading and Writing Japanese";
+ /\s(DS[^\s]+)\s/
+ when :tuttle_flash_card #"Tuttle Kanji Cards";
+ /\s(DT[^\s]+)\s/
+ when :tuttle_dictionary #"The Kanji Dictionary (Tuttle 1996)"
+ /\s(I[^N][^\s]+)\s/
+ when :tuttle_kanji_and_kana #"Kanji & Kana book (Tuttle)";
+ /\s(IN[^\s]+)\s/
+ when :unicode
+ /\s(U[^\s]+)\s/
+ when :four_corner #"The four corner code";
+ /\s(Q[^\s]+)\s/
+ when :heisig
+ /\bL(\d+)\b/
+ when :morohashi_index #"Morohashi Daikanwajiten Index";
+ /\s(MN[^\s]+)\s/
+ when :morohashi_volume_page #"Morohashi Daikanwajiten Volume and Page";
+ /\s(MN[^\s]+)\s/
+ when :henshall #"A Guide To Remembering Japanese Characters";
+ /\s(E[^\s]+)\s/
+ when :gakken #"Gakken Kanji Dictionary";
+ /\s(G[^\s]+)\s/
+ when :japanese_names #"Japanese Names, by P.G. O'Neill";
+ /\s(O[^\s]+)\s/
+ when :cross_reference #"Cross Reference Code";
+ /\sX([^\s]+)\s/
+ when :misclassification #"Mis-classification code";
+ /\s(Z[^\s]+)\s/
+ end
+ end
+
+ #Expects an array of types as symbols (or single symbol)
+ #And an array of lines, or uses member variable
+ #Return every unique occurence of that type within the
+ #file specified
+ #strip_duplicates - this only returns values in the lines
+ #that are not in the database (can be used to import new values)
+ #returned as a hash of arrays of values (key is the symbol)
+ def get_unique_values types, lines=nil, strip_duplicates=false
+ lines ||= @lines
+ if lines.nil?
+ raise ArgumentError, "No value for lines, and no value previously set", caller
+ else
+ @lines = lines
+ end
+ #make sure to return array if only one type
+ #otherwise return hash of arrays
+ single_item =false
+ unless types.class == Array
+ types = [types]
+ single_item =true
+ end
+
+ hash_types={}
+ #create a dictionary for each type
+ types.each {|type|hash_types[type]={}}
+
+ #for each line get the elements of each type
+ #add to dictionary for that type
+ lines.each do |line|
+ types.each do |type|
+ #add the element(s) to the hash
+ #puts "hash_types:#{hash_types}"
+ dict = hash_types[type]
+ hash_types[type] = add_elements(line, type, dict, strip_duplicates)
+ end
+
+ end
+ if single_item
+ #e.g. hash = {:kanji => {"木"=>1,"子"=>1},:onyomi=>{"コウ"=>1}}
+ return hash_types.values[0].keys
+ end
+
+ #e.g. hash = {:kanji => {"木"=>1,"子"=>1},:onyomi=>{"コウ"=>1}}
+ #gets changed to {:kanji => ["木","子"], :onyomi => ["コウ"]}
+ hash_types.keys.each do |k|
+ hash_types[k] =hash_types[k].keys
+ end
+
+ return hash_types
+ end
+
+ def add_elements line, type, dictionary, strip_duplicates
+ elements = get_element(type, line)
+ if strip_duplicates
+ lookup = eval('@' + type.to_s + '_lookup')
+ end
+
+ if elements.is_a? String
+ dictionary[elements]=1
+ #remove from hash if already in database
+ if strip_duplicates
+ if lookup[elements]
+ dictionary.delete(elements)
+ end
+ end
+ elsif elements.is_a? Array
+ elements.each do |e|
+ dictionary[e]=1
+ if strip_duplicates
+ if lookup[e]
+ dictionary.delete e
+ end
+ end
+ end
+ end
+ return dictionary
+ end
+
+ def import_file filename=KANJIDIC, validate=false, delete_all=true
+ lines = read_lines filename
+ import_kanjidic lines, validate, delete_all
+
+ end
+
+ def read_lines filename=KANJIDIC
+ lines = File.open filename, "r" do |f|; f.readlines;end
+ end
+
+ def import_kanjidic lines=nil, validate=false, delete=true
+ unless lines.nil?
+ lines = read_lines
+ end
+ import_reading_lookup_values lines, @lookup_attributes, validate, delete
+ readings, indexes = parse_kanjidic lines
+ import_indexes indexes, validate, delete
+ import_relationships readings, validate, delete
+
+ end
+
+ #returns all the relationships and indexes in the lines
+ def parse_kanjidic lines
+ line_number=1
+ # get id values from the tables for the various attributes such as kunyomi, onyomi etc
+ # to be used in the join tables
+ readings_to_import= {}
+ @lookup_attributes.each do |column|
+ #stores readings in a hash of arrays with the key being
+ #the attribute name e.g. :nanori, :kunyomi, etc
+ readings_to_import[column]=[]
+ end
+
+
+ #create empty arrays to store index values
+ indexes_to_import= [] #2D array of [[dictionary_id, kanji_id, index_value],...]
+
+ lines.each do |line|
+ unless line_number == 1
+ kanji = line[0].to_s
+ kanji_id = @kanji_lookup[kanji]
+ #for each of nanori, onyomi, english_words, pinyin etc
+ @lookup_attributes.each do |column|
+ #get each of the multiple value attributes and append them to an array
+ #to import at the end
+ klass = eval(column.to_s.capitalize)
+ relation_klass = eval(column.to_s.capitalize.pluralize+"Kanji")
+ lookup = "@#{column}_lookup"
+ #puts lookup
+ lookup = eval(lookup)
+
+ values = get_element(column, line)
+ values.each do |value|
+ #e.g. equivalent to o=Onyomi.find_by_onyomi onyomi
+ relation_id = lookup[value]
+ # e.g. equivalent to array << OnyomisKanji.new(:kanji_id=>id,:onyomi_id =>o.id)
+ readings_to_import[column] << [kanji_id ,relation_id]
+ end
+ end
+
+ #for the indexes we have a KanjiIndex table an Dictionaries table
+ #and a KanjiIndex has a dictionary_id column
+ @index_names.each do |index_name|
+ indexes_to_import += get_dictionary_index(index_name, line)
+ end
+
+ end
+ line_number +=1
+ end
+ return readings_to_import, indexes_to_import
+ end
+end
4 app/models/korean.rb
@@ -0,0 +1,4 @@
+class Korean < ActiveRecord::Base
+ has_many :koreans_kanji
+ has_many :kanjis, :through => :koreans_kanji
+end
4 app/models/koreans_kanji.rb
@@ -0,0 +1,4 @@
+class KoreansKanji < ActiveRecord::Base
+ belongs_to :kanji
+ belongs_to :korean
+end
14 app/models/kunyomi.rb
@@ -0,0 +1,14 @@
+class Kunyomi < ActiveRecord::Base
+ has_many :kunyomis_kanjis
+ has_many :kanjis, :through => :kunyomis_kanjis
+
+ has_many :kanji_words, :through => :kunyomi_readings
+ has_many :english_meanings, :through => {:kanji_words => :english_meanings}
+ def kunyomi
+ ( read_attribute :kunyomi)#.force_encoding 'utf-8'
+ end
+ def to_s
+ kunyomi
+ end
+
+end
4 app/models/kunyomi_readings.rb
@@ -0,0 +1,4 @@
+class KunyomiReadings < ActiveRecord::Base
+ belongs_to :kunyomi
+ belongs_to :kanji_word
+end
8 app/models/kunyomis_kanji.rb
@@ -0,0 +1,8 @@
+class KunyomisKanji < ActiveRecord::Base
+ belongs_to :kunyomi
+ belongs_to :kanji
+ def to_s
+ kunyomi.to_s + kanji.to_s
+ end
+
+end
3 app/models/kyuujitai.rb
@@ -0,0 +1,3 @@
+class Kyuujitai < ActiveRecord::Base
+ belongs_to :kanji
+end
2 app/models/language.rb
@@ -0,0 +1,2 @@
+class Language < ActiveRecord::Base
+end
4 app/models/meanings_kanji.rb
@@ -0,0 +1,4 @@
+class MeaningsKanji < ActiveRecord::Base
+ belongs_to :kanji
+ belongs_to :meaning
+end
4 app/models/nanori.rb
@@ -0,0 +1,4 @@
+class Nanori < ActiveRecord::Base
+ has_many :nanoris_kanjis
+ has_many :kanjis, :through => :nanoris_kanjis
+end
4 app/models/nanoris_kanji.rb
@@ -0,0 +1,4 @@
+class NanorisKanji < ActiveRecord::Base
+ belongs_to :nanori
+ belongs_to :kanji
+end
8 app/models/onyomi.rb
@@ -0,0 +1,8 @@
+class Onyomi < ActiveRecord::Base
+ has_many :onyomis_kanjis
+
+ has_many :kanjis, :through => :onyomis_kanjis
+ def to_s
+ onyomi
+ end
+end
4 app/models/onyomi_readings.rb
@@ -0,0 +1,4 @@
+class OnyomiReadings < ActiveRecord::Base
+ belongs_to :onyomi
+ belongs_to :kanji_word
+end
7 app/models/onyomis_kanji.rb
@@ -0,0 +1,7 @@
+class OnyomisKanji < ActiveRecord::Base
+ belongs_to :onyomi
+ belongs_to :kanji
+ def to_s
+ onyomi.to_s + kanji.to_s
+ end
+end
4 app/models/pinyin.rb
@@ -0,0 +1,4 @@
+class Pinyin < ActiveRecord::Base
+ belongs_to :pinyins_kanji
+ has_many :kanjis, :through => :pinyins_kanji
+end
4 app/models/pinyins_kanji.rb
@@ -0,0 +1,4 @@
+class PinyinsKanji < ActiveRecord::Base
+ belongs_to :pinyin
+ belongs_to :kanji
+end
16 app/models/primitive.rb
@@ -0,0 +1,16 @@
+class Primitive < ActiveRecord::Base
+ has_many :primitives_kanjis
+ has_many :kanjis, :through => :primitives_kanjis
+
+
+
+
+
+
+
+
+
+
+ belongs_to :equivalent_kanji, :class_name => "Kanji",
+ :foreign_key => "equivalent_kanji_id"
+end
5 app/models/primitives_kanji.rb
@@ -0,0 +1,5 @@
+class PrimitivesKanji < ActiveRecord::Base
+ belongs_to :primitive
+ belongs_to :kanji
+ set_primary_keys :primitive_id, :kanji_id
+end
4 app/models/skip.rb
@@ -0,0 +1,4 @@
+class Skip < ActiveRecord::Base
+ has_many :skips_kanjis
+ has_many :kanjis, :through => :skips_kanjis
+end
4 app/models/skips_kanji.rb
@@ -0,0 +1,4 @@
+class SkipsKanji < ActiveRecord::Base
+ belongs_to :skip
+ belongs_to :kanji
+end
2 app/models/tanaka_english_word.rb
@@ -0,0 +1,2 @@
+class TanakaEnglishWord < ActiveRecord::Base
+end
2 app/models/tanaka_japanese_word.rb
@@ -0,0 +1,2 @@
+class TanakaJapaneseWord < ActiveRecord::Base
+end
2 app/models/tanaka_sentence.rb
@@ -0,0 +1,2 @@
+class TanakaSentence < ActiveRecord::Base
+end
110 config/boot.rb
@@ -0,0 +1,110 @@
+# Don't change this file!
+# Configure your app in config/environment.rb and config/environments/*.rb
+
+RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
+
+module Rails
+ class << self
+ def boot!
+ unless booted?
+ preinitialize
+ pick_boot.run
+ end
+ end
+
+ def booted?
+ defined? Rails::Initializer
+ end
+
+ def pick_boot
+ (vendor_rails? ? VendorBoot : GemBoot).new
+ end
+
+ def vendor_rails?
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
+ end
+
+ def preinitialize
+ load(preinitializer_path) if File.exist?(preinitializer_path)
+ end
+
+ def preinitializer_path
+ "#{RAILS_ROOT}/config/preinitializer.rb"
+ end
+ end
+
+ class Boot
+ def run
+ load_initializer
+ Rails::Initializer.run(:set_load_path)
+ end
+ end
+
+ class VendorBoot < Boot
+ def load_initializer
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
+ Rails::Initializer.run(:install_gem_spec_stubs)
+ Rails::GemDependency.add_frozen_gem_path
+ end
+ end
+
+ class GemBoot < Boot
+ def load_initializer
+ self.class.load_rubygems
+ load_rails_gem
+ require 'initializer'
+ end
+
+ def load_rails_gem
+ if version = self.class.gem_version
+ gem 'rails', version
+ else
+ gem 'rails'
+ end
+ rescue Gem::LoadError => load_error
+ $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
+ exit 1
+ end
+
+ class << self
+ def rubygems_version
+ Gem::RubyGemsVersion rescue nil
+ end
+
+ def gem_version
+ if defined? RAILS_GEM_VERSION
+ RAILS_GEM_VERSION
+ elsif ENV.include?('RAILS_GEM_VERSION')
+ ENV['RAILS_GEM_VERSION']
+ else
+ parse_gem_version(read_environment_rb)
+ end
+ end
+
+ def load_rubygems
+ min_version = '1.3.2'
+ require 'rubygems'
+ unless rubygems_version >= min_version
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
+ exit 1
+ end
+
+ rescue LoadError
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
+ exit 1
+ end
+
+ def parse_gem_version(text)
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
+ end
+
+ private
+ def read_environment_rb
+ File.read("#{RAILS_ROOT}/config/environment.rb")
+ end
+ end
+ end
+end
+
+# All that for this:
+Rails.boot!
7 config/cucumber.yml
@@ -0,0 +1,7 @@
+<%
+rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
+rerun_opts = rerun.to_s.strip.empty? ? "--format progress features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
+std_opts = "#{rerun_opts} --format rerun --out rerun.txt --strict --tags ~@wip"
+%>
+default: <%= std_opts %>
+wip: --tags @wip:3 --wip features
54 config/environment.rb
@@ -0,0 +1,54 @@
+# Be sure to restart your server when you modify this file
+
+# Specifies gem version of Rails to use when vendor/rails is not present
+RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
+
+# Bootstrap the Rails environment, frameworks, and default configuration
+require File.join(File.dirname(__FILE__), 'boot')
+
+Rails::Initializer.run do |config|
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Add additional load paths for your own custom dirs
+ # config.load_paths += %W( #{RAILS_ROOT}/extras )
+
+ # Specify gems that this application depends on and have them installed with rake gems:install
+ # config.gem "bj"
+ # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
+ # config.gem "sqlite3-ruby", :lib => "sqlite3"
+ # config.gem "aws-s3", :lib => "aws/s3"
+ config.gem "haml"
+ config.gem "ar-extensions", :lib => 'ar-extensions', :source => 'http://gems.github.com'
+ config.gem "authlogic"
+ config.gem 'aub-record_filter', :lib => 'record_filter', :source => 'http://gems.github.com'
+ config.gem "authlogic-oid", :lib => "authlogic_openid"
+ config.gem "composite_primary_keys"
+ config.gem "rspec", :lib => false, :version => ">= 1.2.9"
+ config.gem "rspec-rails", :lib => false, :version => ">= 1.2.9"
+ config.gem "will_paginate"
+ config.gem "sqlite3-ruby", :lib => "sqlite3"
+
+ config.gem 'metric_fu', :version => '1.3.0', :lib => 'metric_fu'
+
+
+ # Only load the plugins named here, in the order given (default is alphabetical).
+ # :all can be used as a placeholder for all plugins not explicitly named
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Skip frameworks you're not going to use. To use Rails without a database,
+ # you must remove the Active Record framework.
+ # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
+
+ # Activate observers that should always be running
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names.
+ config.time_zone = 'UTC'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
+ # config.i18n.default_locale = :de
+end
27 config/environments/cucumber.rb
@@ -0,0 +1,27 @@
+# Edit at your own peril - it's recommended to regenerate this file
+# in the future when you upgrade to a newer version of Cucumber.
+
+# IMPORTANT: Setting config.cache_classes to false is known to
+# break Cucumber's use_transactional_fixtures method.
+# For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165
+config.cache_classes = true
+
+# Log error messages when you accidentally call methods on nil.
+config.whiny_nils = true
+
+# Show full error reports and disable caching
+config.action_controller.consider_all_requests_local = true
+config.action_controller.perform_caching = false
+
+# Disable request forgery protection in test environment
+config.action_controller.allow_forgery_protection = false
+
+# Tell Action Mailer not to deliver emails to the real world.
+# The :test delivery method accumulates sent emails in the
+# ActionMailer::Base.deliveries array.
+config.action_mailer.delivery_method = :test
+
+config.gem 'cucumber-rails', :lib => false, :version => '>=0.3.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber-rails'))
+config.gem 'database_cleaner', :lib => false, :version => '>=0.5.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/database_cleaner'))
+config.gem 'webrat', :lib => false, :version => '>=0.7.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/webrat'))
+
17 config/environments/development.rb
@@ -0,0 +1,17 @@
+# Settings specified here will take precedence over those in config/environment.rb
+
+# In the development environment your application's code is reloaded on
+# every request. This slows down response time but is perfect for development
+# since you don't have to restart the webserver when you make code changes.
+config.cache_classes = false
+
+# Log error messages when you accidentally call methods on nil.
+config.whiny_nils = true
+
+# Show full error reports and disable caching
+config.action_controller.consider_all_requests_local = true
+config.action_view.debug_rjs = true
+config.action_controller.perform_caching = false
+
+# Don't care if the mailer can't send
+config.action_mailer.raise_delivery_errors = false
28 config/environments/production.rb
@@ -0,0 +1,28 @@
+# Settings specified here will take precedence over those in config/environment.rb
+
+# The production environment is meant for finished, "live" apps.
+# Code is not reloaded between requests
+config.cache_classes = true
+
+# Full error reports are disabled and caching is turned on
+config.action_controller.consider_all_requests_local = false
+config.action_controller.perform_caching = true
+config.action_view.cache_template_loading = true
+
+# See everything in the log (default is :info)
+# config.log_level = :debug
+
+# Use a different logger for distributed setups
+# config.logger = SyslogLogger.new
+
+# Use a different cache store in production
+# config.cache_store = :mem_cache_store
+
+# Enable serving of images, stylesheets, and javascripts from an asset server
+# config.action_controller.asset_host = "http://assets.example.com"
+
+# Disable delivery errors, bad email addresses will be ignored
+# config.action_mailer.raise_delivery_errors = false
+
+# Enable threaded mode
+# config.threadsafe!
30 config/environments/test.rb
@@ -0,0 +1,30 @@
+# Settings specified here will take precedence over those in config/environment.rb
+
+# The test environment is used exclusively to run your application's
+# test suite. You never need to work with it otherwise. Remember that
+# your test database is "scratch space" for the test suite and is wiped
+# and recreated between test runs. Don't rely on the data there!
+config.cache_classes = true
+
+# Log error messages when you accidentally call methods on nil.
+config.whiny_nils = true
+
+# Show full error reports and disable caching
+config.action_controller.consider_all_requests_local = true
+config.action_controller.perform_caching = false
+config.action_view.cache_template_loading = true
+
+# Disable request forgery protection in test environment
+config.action_controller.allow_forgery_protection = false
+
+# Tell Action Mailer not to deliver emails to the real world.
+# The :test delivery method accumulates sent emails in the
+# ActionMailer::Base.deliveries array.
+config.action_mailer.delivery_method = :test
+
+# Use SQL instead of Active Record's schema dumper when creating the test database.
+# This is necessary if your schema can't be completely dumped by the schema dumper,
+# like if you have constraints or database-specific column types
+# config.active_record.schema_format = :sql
+
+ config.gem 'rspec-rails', :version => '>= 1.3.2', :lib => false unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))
7 config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying do debug a problem that might steem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
10 config/initializers/inflections.rb
@@ -0,0 +1,10 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format
+# (all these examples are active by default):
+# ActiveSupport::Inflector.inflections do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
5 config/initializers/mime_types.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
+# Mime::Type.register_alias "text/html", :iphone
21 config/initializers/new_rails_defaults.rb
@@ -0,0 +1,21 @@
+# Be sure to restart your server when you modify this file.
+
+# These settings change the behavior of Rails 2 apps and will be defaults
+# for Rails 3. You can remove this initializer when Rails 3 is released.
+
+if defined?(ActiveRecord)
+ # Include Active Record class name as root for JSON serialized output.
+ ActiveRecord::Base.include_root_in_json = true
+
+ # Store the full class name (including module namespace) in STI type column.
+ ActiveRecord::Base.store_full_sti_class = true
+end
+
+ActionController::Routing.generate_best_match = false
+
+# Use ISO 8601 format for JSON serialized times and dates.
+ActiveSupport.use_standard_json_time_format = true
+
+# Don't escape HTML entities in JSON, leave that for the #json_escape helper.
+# if you're including raw json in an HTML page.
+ActiveSupport.escape_html_entities_in_json = false
15 config/initializers/session_store.rb
@@ -0,0 +1,15 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key for verifying cookie session data integrity.
+# If you change this key, all old sessions will become invalid!
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+ActionController::Base.session = {
+ :key => '_importer_rails_session',
+ :secret => '74eb0276d641fa9095ababe7c588027f72554af81d45ef3b673234b42808d93c4f705620d9dca56273398f9f125a1d9deb86f7cab2b669ab81a504c0428ba8a1'
+}
+
+# Use the database for sessions instead of the cookie-based default,
+# which shouldn't be used to store highly confidential information
+# (create the session table with "rake db:sessions:create")
+# ActionController::Base.session_store = :active_record_store
5 config/locales/en.yml
@@ -0,0 +1,5 @@
+# Sample localization file for English. Add more files in this directory for other locales.
+# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+
+en:
+ hello: "Hello world"
43 config/routes.rb
@@ -0,0 +1,43 @@
+ActionController::Routing::Routes.draw do |map|
+ # The priority is based upon order of creation: first created -> highest priority.
+
+ # Sample of regular route:
+ # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
+ # Keep in mind you can assign values other than :controller and :action
+
+ # Sample of named route:
+ # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
+ # This route can be invoked with purchase_url(:id => product.id)
+
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
+ # map.resources :products
+
+ # Sample resource route with options:
+ # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
+
+ # Sample resource route with sub-resources:
+ # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
+
+ # Sample resource route with more complex sub-resources
+ # map.resources :products do |products|
+ # products.resources :comments
+ # products.resources :sales, :collection => { :recent => :get }
+ # end
+
+ # Sample resource route within a namespace:
+ # map.namespace :admin do |admin|
+ # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
+ # admin.resources :products
+ # end
+
+ # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
+ # map.root :controller => "welcome"
+
+ # See how all your routes lay out with "rake routes"
+
+ # Install the default routes as the lowest priority.
+ # Note: These default routes make all actions in every controller accessible via GET requests. You should
+ # consider removing or commenting them out if you're using named routes and resources.
+ map.connect ':controller/:action/:id'
+ map.connect ':controller/:action/:id.:format'
+end
24 connection.rb
@@ -0,0 +1,24 @@
+DATABASE_CONFIG = 'database.yml'
+MODELS_DIRECTORY = 'models'
+
+require 'active_record'
+#https://rails.lighthouseapp.com/projects/8994/tickets/2577-when-using-activerecordassociations-outside-of-rails-a-nameerror-is-thrown
+ActiveRecord::ActiveRecordError
+require 'composite_primary_keys'
+require 'yaml'
+require 'ar-extensions'
+require "authlogic"
+gem 'aub-record_filter'
+require 'record_filter'
+gem "authlogic-oid"
+
+ActiveRecord::Base.logger = Logger.new('temp.log')
+dbconfig = YAML::load(File.open(DATABASE_CONFIG))["development"]
+ActiveRecord::Base.establish_connection(dbconfig)
+files = Dir.glob MODELS_DIRECTORY + "/*.rb"
+
+files.each do |f|
+ require f unless f =~ /user/
+
+end
+
BIN db/development.sqlite3
Binary file not shown.
175,499 db/edict
175,499 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
2,116 db/jlpt.csv
2,116 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
1,946 db/joyo.csv
1,946 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
6,356 db/kanjidic
6,356 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
6,355 db/kradfile
6,355 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
397 db/migrate/20100329165705_initial_migration.rb
@@ -0,0 +1,397 @@
+class InitialMigration < ActiveRecord::Migration
+ def self.up
+
+ create_table "dictionaries", :force => true do |t|
+ t.string "name"
+ t.string "description"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "edict_mappings", :force => true do |t|
+ t.integer "english_word_id"
+ t.integer "japanese_word_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "english_words", :force => true do |t|
+ t.string "word"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "heisig_keywords", :force => true do |t|
+ t.integer "heisig_id"
+ t.integer "language_id"
+ t.string "keyword"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "heisig_edition_id"
+ end
+
+ add_index "heisig_keywords", ["heisig_edition_id"], :name => "index_heisig_keywords_on_heisig_edition_id"
+ add_index "heisig_keywords", ["heisig_id"], :name => "index_heisig_keywords_on_heisig_id"
+ add_index "heisig_keywords", ["keyword"], :name => "index_heisig_keywords_on_keyword"
+ add_index "heisig_keywords", ["language_id"], :name => "index_heisig_keywords_on_language_id"
+
+ create_table "heisigs", :force => true do |t|
+ t.integer "kanji_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "heisig_id"
+ t.integer "lesson_id"
+ end
+
+ add_index "heisigs", ["heisig_id"], :name => "index_heisigs_on_heisig_id"
+ add_index "heisigs", ["kanji_id"], :name => "index_heisigs_on_kanji_id"
+ add_index "heisigs", ["lesson_id"], :name => "index_heisigs_on_lesson_id"
+
+ create_table "japanese_words", :force => true do |t|
+ t.string "word"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "jlpts_kanjis", :force => true do |t|
+ t.string "level", :limit => 5
+ t.integer "kanji_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "joyos_kanjis", :force => true do |t|
+ t.integer "kanji_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "level", :limit => 5
+ end
+
+ create_table "kanji_lookups", :force => true do |t|
+ t.integer "dictionary_id"
+ t.integer "kanji_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "dictionary_index_value"
+ end
+
+ create_table "kanjis", :force => true do |t|
+ t.text "kanji"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "stroke_count"
+ t.integer "ordinal_id"
+ t.integer "frequency"
+ t.integer "kanji_tree_edits_count", :default => 0
+ t.string "status", :default => "U"
+ t.integer "occurence_count"
+ t.decimal "frequency_percentage", :precision => 7, :scale => 5
+ t.integer "rank"
+ t.decimal "cumulative_frequency", :precision => 10, :scale => 7
+ end
+
+ add_index "kanjis", ["frequency"], :name => "index_kanjis_on_frequency"
+ add_index "kanjis", ["frequency_percentage"], :name => "index_kanjis_on_frequency_percentage"
+ add_index "kanjis", ["kanji"], :name => "index_kanjis_on_kanji"
+ add_index "kanjis", ["occurence_count"], :name => "index_kanjis_on_occurence_count"
+ add_index "kanjis", ["rank"], :name => "index_kanjis_on_rank"
+
+ create_table "koreans", :force => true do |t|
+ t.string "korean"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "koreans_kanjis", :force => true do |t|
+ t.integer "korean_id"
+ t.integer "kanji_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "kunyomis", :force => true do |t|
+ t.string "kunyomi"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "kunyomis", ["kunyomi"], :name => "index_kunyomis_on_kunyomi"
+
+ create_table "kunyomis_kanjis", :id => false, :force => true do |t|
+ t.integer "kanji_id"
+ t.integer "kunyomi_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "kunyomis_kanjis", ["kanji_id"], :name => "index_kunyomis_kanjis_on_kanji_id"
+ add_index "kunyomis_kanjis", ["kunyomi_id"], :name => "index_kunyomis_kanjis_on_kunyomi_id"
+
+ create_table "kyuujitais", :force => true do |t|
+ t.integer "kanji_id"
+ t.string "kyuujitai"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "kyuujitais", ["kanji_id"], :name => "index_kyuujitais_on_kanji_id"
+ add_index "kyuujitais", ["kyuujitai"], :name => "index_kyuujitais_on_kyuujitai"
+
+ create_table "languages", :force => true do |t|
+ t.string "language"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "meanings_kanjis", :id => false, :force => true do |t|
+ t.integer "kanji_id"
+ t.string "meaning_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "meanings_kanjis", ["kanji_id"], :name => "index_meanings_kanjis_on_kanji_id"
+ add_index "meanings_kanjis", ["meaning_id"], :name => "index_meanings_kanjis_on_meaning_id"
+
+ create_table "nanoris", :force => true do |t|
+ t.string "nanori"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "nanoris", ["nanori"], :name => "index_nanoris_on_nanori"
+
+ create_table "nanoris_kanjis", :id => false, :force => true do |t|
+ t.integer "kanji_id"
+ t.integer "nanori_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "nanoris_kanjis", ["kanji_id"], :name => "index_nanoris_kanjis_on_kanji_id"
+ add_index "nanoris_kanjis", ["nanori_id"], :name => "index_nanoris_kanjis_on_nanori_id"
+
+ create_table "onyomis", :force => true do |t|
+ t.string "onyomi"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "onyomis", ["onyomi"], :name => "index_onyomis_on_onyomi"
+
+ create_table "onyomis_kanjis", :id => false, :force => true do |t|
+ t.integer "kanji_id"
+ t.integer "onyomi_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "onyomis_kanjis", ["kanji_id"], :name => "index_onyomis_kanjis_on_kanji_id"
+ add_index "onyomis_kanjis", ["onyomi_id"], :name => "index_onyomis_kanjis_on_onyomi_id"
+
+ create_table "pinyins", :force => true do |t|
+ t.integer "kanji_id"
+ t.string "pinyin"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "pinyins", ["pinyin"], :name => "index_pinyins_on_pinyin"
+
+ create_table "pinyins_kanjis", :force => true do |t|
+ t.integer "kanji_id"
+ t.integer "pinyin_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "pinyins_kanjis", ["kanji_id"], :name => "index_pinyins_kanjis_on_kanji_id"
+ add_index "pinyins_kanjis", ["pinyin_id", "kanji_id"], :name => "index_pinyins_kanjis_on_pinyin_id_and_kanji_id"
+ add_index "pinyins_kanjis", ["pinyin_id"], :name => "index_pinyins_kanjis_on_pinyin_id"
+
+ create_table "primitives", :force => true do |t|
+ t.string "primitive"
+ t.string "filename"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "equivalent_kanji_id"
+ t.integer "stroke_count"
+ end
+
+ add_index "primitives", ["equivalent_kanji_id"], :name => "index_primitives_on_equivalent_kanji_id"
+ add_index "primitives", ["filename"], :name => "index_primitives_on_filename"
+ add_index "primitives", ["primitive"], :name => "index_primitives_on_primitive"
+ add_index "primitives", ["stroke_count"], :name => "index_primitives_on_stroke_count"
+
+ create_table "primitives_kanjis", :id => false, :force => true do |t|
+ t.integer "primitive_id"
+ t.integer "kanji_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "primitives_kanjis", ["kanji_id"], :name => "index_primitives_kanjis_on_kanji_id"
+ add_index "primitives_kanjis", ["primitive_id"], :name => "index_primitives_kanjis_on_primitive_id"
+
+ create_table "skips", :force => true do |t|
+ t.string "skip_pattern"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "skips", ["skip_pattern"], :name => "index_skips_on_skip_pattern"
+
+ create_table "skips_kanjis", :force => true do |t|
+ t.integer "skip_id"
+ t.integer "kanji_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "skips_kanjis", ["kanji_id"], :name => "index_skips_kanjis_on_kanji_id"
+ add_index "skips_kanjis", ["skip_id"], :name => "index_skips_kanjis_on_skip_id"
+
+ create_table "tanaka_english_words", :force => true do |t|
+ t.integer "tanaka_sentence_id"
+ t.integer "english_word_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "tanaka_japanese_words", :force => true do |t|
+ t.integer "tanaka_sentence_id"
+ t.integer "japanese_word_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "tanaka_sentences", :force => true do |t|
+ t.string "english"
+ t.string "japanese"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+
+ end
+
+ def self.down
+
+
+ drop_table "tanaka_sentences"
+
+ drop_table "tanaka_japanese_words"
+
+ drop_table "tanaka_english_words"
+
+ remove_index "skips_kanjis", :name => "index_skips_kanjis_on_skip_id"
+ remove_index "skips_kanjis", :name => "index_skips_kanjis_on_kanji_id"
+
+ drop_table "skips_kanjis"
+
+ remove_index "skips", :name => "index_skips_on_skip_pattern"
+
+ drop_table "skips"
+
+ remove_index "primitives_kanjis", :name => "index_primitives_kanjis_on_primitive_id"
+ remove_index "primitives_kanjis", :name => "index_primitives_kanjis_on_kanji_id"
+
+ drop_table "primitives_kanjis"
+
+ remove_index "primitives", :name => "index_primitives_on_stroke_count"
+ remove_index "primitives", :name => "index_primitives_on_primitive"
+ remove_index "primitives", :name => "index_primitives_on_filename"
+ remove_index "primitives", :name => "index_primitives_on_equivalent_kanji_id"
+
+ drop_table "primitives"
+
+ remove_index "pinyins_kanjis", :name => "index_pinyins_kanjis_on_pinyin_id"
+ remove_index "pinyins_kanjis", :name => "index_pinyins_kanjis_on_pinyin_id_and_kanji_id"
+ remove_index "pinyins_kanjis", :name => "index_pinyins_kanjis_on_kanji_id"
+
+ drop_table "pinyins_kanjis"
+
+ remove_index "pinyins", :name => "index_pinyins_on_pinyin"
+
+ drop_table "pinyins"
+
+ remove_index "onyomis_kanjis", :name => "index_onyomis_kanjis_on_onyomi_id"
+ remove_index "onyomis_kanjis", :name => "index_onyomis_kanjis_on_kanji_id"
+
+ drop_table "onyomis_kanjis"
+
+ remove_index "onyomis", :name => "index_onyomis_on_onyomi"
+
+ drop_table "onyomis"
+
+ remove_index "nanoris_kanjis", :name => "index_nanoris_kanjis_on_nanori_id"
+ remove_index "nanoris_kanjis", :name => "index_nanoris_kanjis_on_kanji_id"
+
+ drop_table "nanoris_kanjis"
+
+ remove_index "nanoris", :name => "index_nanoris_on_nanori"
+
+ drop_table "nanoris"
+
+ remove_index "meanings_kanjis", :name => "index_meanings_kanjis_on_meaning_id"
+ remove_index "meanings_kanjis", :name => "index_meanings_kanjis_on_kanji_id"
+
+ drop_table "meanings_kanjis"
+
+ drop_table "languages"
+
+ remove_index "kyuujitais", :name => "index_kyuujitais_on_kyuujitai"
+ remove_index "kyuujitais", :name => "index_kyuujitais_on_kanji_id"
+
+ drop_table "kyuujitais"
+
+ remove_index "kunyomis_kanjis", :name => "index_kunyomis_kanjis_on_kunyomi_id"
+ remove_index "kunyomis_kanjis", :name => "index_kunyomis_kanjis_on_kanji_id"
+
+ drop_table "kunyomis_kanjis"
+
+ remove_index "kunyomis", :name => "index_kunyomis_on_kunyomi"
+
+ drop_table "kunyomis"
+
+ drop_table "koreans_kanjis"
+
+ drop_table "koreans"
+
+ remove_index "kanjis", :name => "index_kanjis_on_rank"
+ remove_index "kanjis", :name => "index_kanjis_on_occurence_count"
+ remove_index "kanjis", :name => "index_kanjis_on_kanji"
+ remove_index "kanjis", :name => "index_kanjis_on_frequency_percentage"
+ remove_index "kanjis", :name => "index_kanjis_on_frequency"
+
+ drop_table "kanjis"
+
+ drop_table "kanji_lookups"
+
+ drop_table "joyos_kanjis"
+
+ drop_table "jlpts_kanjis"
+
+ drop_table "japanese_words"
+
+ remove_index "heisigs", :name => "index_heisigs_on_lesson_id"
+ remove_index "heisigs", :name => "index_heisigs_on_kanji_id"
+ remove_index "heisigs", :name => "index_heisigs_on_heisig_id"
+
+ drop_table "heisigs"
+
+ remove_index "heisig_keywords", :name => "index_heisig_keywords_on_language_id"
+ remove_index "heisig_keywords", :name => "index_heisig_keywords_on_keyword"
+ remove_index "heisig_keywords", :name => "index_heisig_keywords_on_heisig_id"
+ remove_index "heisig_keywords", :name => "index_heisig_keywords_on_heisig_edition_id"
+
+ drop_table "heisig_keywords"
+
+ drop_table "english_words"
+
+ drop_table "edict_mappings"
+
+ drop_table "dictionaries"
+
+ end
+end
285 db/schema.rb
@@ -0,0 +1,285 @@
+# This file is auto-generated from the current state of the database. Instead of editing this file,
+# please use the migrations feature of Active Record to incrementally modify your database, and
+# then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your database schema. If you need
+# to create the application database on another system, you should be using db:schema:load, not running
+# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20100329165705) do
+
+ create_table "dictionaries", :force => true do |t|
+ t.string "name"
+ t.string "description"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "edict_mappings", :force => true do |t|
+ t.integer "english_word_id"
+ t.integer "japanese_word_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "english_words", :force => true do |t|
+ t.string "word"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "heisig_keywords", :force => true do |t|
+ t.integer "heisig_id"
+ t.integer "language_id"
+ t.string "keyword"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "heisig_edition_id"
+ end
+
+ add_index "heisig_keywords", ["heisig_edition_id"], :name => "index_heisig_keywords_on_heisig_edition_id