Last active
August 19, 2019 02:21
-
-
Save zunda/c5f50abc1a2139d0edc1a3e6ddae2c84 to your computer and use it in GitHub Desktop.
macOSでMastodonを走らせてみる。https://qiita.com/zunda/items/5f8a0a8ee1e7c297dcd4 も参照してみてください。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
入れるのが大変なGemは入れない: | |
$ curl -o - https://gist.githubusercontent.com/zunda/c5f50abc1a2139d0edc1a3e6ddae2c84/raw/2a825d75fa64e5986abf685a091fc9c3ee3bdedf/run-mastodon-on-macos.patch | patch | |
PostgreSQLを走らせておいて、 | |
$ export RAILS_ENV=development | |
$ bundle install --path=vendor/bundle | |
$ bundle exec rake assets:precompile | |
$ bundle exec rake db:drop | |
$ bundle exec rake db:setup | |
$ bundle exec rake db:migrate | |
$ bundle exec bin/tootctl accounts create zunda --email=zundan@gmail.com | |
OK | |
New password: ******************************** | |
$ redis-server & | |
$ npm start & | |
$ bundle exec rails s | |
これで http://localhost:3000/ からログインできる。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Gemfile b/Gemfile | |
index 7440d5c5b..d82cb650a 100644 | |
--- a/Gemfile | |
+++ b/Gemfile | |
@@ -29,7 +29,6 @@ gem 'browser' | |
gem 'charlock_holmes', '~> 0.7.6' | |
gem 'iso-639' | |
gem 'chewy', '~> 5.0' | |
-gem 'cld3', '~> 3.2.0' | |
gem 'devise', '~> 4.5' | |
gem 'devise-two-factor', '~> 3.0' | |
@@ -53,7 +52,6 @@ gem 'http', '~> 3.3' | |
gem 'http_accept_language', '~> 2.1' | |
gem 'http_parser.rb', '~> 0.6', git: 'https://github.com/tmm1/http_parser.rb', ref: '54b17ba8c7d8d20a16dfc65d1775241833219cf2' | |
gem 'httplog', '~> 1.1' | |
-gem 'idn-ruby', require: 'idn' | |
gem 'kaminari', '~> 1.1' | |
gem 'link_header', '~> 0.0' | |
gem 'mime-types', '~> 3.2', require: 'mime/types/columnar' | |
diff --git a/Gemfile.lock b/Gemfile.lock | |
index 3d82149b8..2b64a36fa 100644 | |
--- a/Gemfile.lock | |
+++ b/Gemfile.lock | |
@@ -142,8 +142,6 @@ GEM | |
elasticsearch (>= 2.0.0) | |
elasticsearch-dsl | |
chunky_png (1.3.10) | |
- cld3 (3.2.2) | |
- ffi (>= 1.1.0, < 1.10.0) | |
climate_control (0.2.0) | |
cocaine (0.5.8) | |
climate_control (>= 0.0.3, < 1.0) | |
@@ -281,7 +279,6 @@ GEM | |
rails-i18n | |
rainbow (>= 2.2.2, < 4.0) | |
terminal-table (>= 1.5.1) | |
- idn-ruby (0.1.0) | |
ipaddress (0.8.3) | |
iso-639 (0.2.8) | |
jaro_winkler (1.5.1) | |
@@ -668,7 +665,6 @@ DEPENDENCIES | |
capybara (~> 3.11) | |
charlock_holmes (~> 0.7.6) | |
chewy (~> 5.0) | |
- cld3 (~> 3.2.0) | |
climate_control (~> 0.2) | |
derailed_benchmarks | |
devise (~> 4.5) | |
@@ -692,7 +688,6 @@ DEPENDENCIES | |
http_parser.rb (~> 0.6)! | |
httplog (~> 1.1) | |
i18n-tasks (~> 0.9) | |
- idn-ruby | |
iso-639 | |
json-ld (~> 2.2) | |
kaminari (~> 1.1) | |
diff --git a/app/lib/language_detector.rb b/app/lib/language_detector.rb | |
index 58c8e2069..e4d8f63d3 100644 | |
--- a/app/lib/language_detector.rb | |
+++ b/app/lib/language_detector.rb | |
@@ -5,10 +5,6 @@ class LanguageDetector | |
CHARACTER_THRESHOLD = 140 | |
- def initialize | |
- @identifier = CLD3::NNetLanguageIdentifier.new(1, 2048) | |
- end | |
- | |
def detect(text, account) | |
input_text = prepare_text(text) | |
return if input_text.blank? | |
@@ -17,9 +13,7 @@ class LanguageDetector | |
end | |
def language_names | |
- @language_names = | |
- CLD3::TaskContextParams::LANGUAGE_NAMES.map { |name| iso6391(name.to_s).to_sym } | |
- .uniq | |
+ [:en] | |
end | |
private | |
@@ -35,8 +29,7 @@ class LanguageDetector | |
def detect_language_code(text) | |
return if unreliable_input?(text) | |
- result = @identifier.find_language(text) | |
- iso6391(result.language.to_s).to_sym if result.reliable? | |
+ return :en | |
end | |
def iso6391(bcp47) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment