Skip to content

Commit

Permalink
Some enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
agordillo committed Apr 3, 2017
1 parent 5ded34c commit 97685ba
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/recommender_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def self.TF(word,text)

# Inverse Document Frequency (IDF)
def self.IDF(word)
Math::log(EuropeanaRS::Application::config.repository_total_entries/(1+(EuropeanaRS::Application::config.words[word] || 0)).to_f)
Math::log((2+EuropeanaRS::Application::config.repository_total_entries)/(1+(EuropeanaRS::Application::config.words[word] || 0)).to_f)
end

# TF-IDF
Expand Down
1 change: 1 addition & 0 deletions config/database.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ development:
adapter: postgresql
encoding: unicode
database: europeanars_development
host: localhost
pool: 5
username: username
password: password
Expand Down
6 changes: 5 additions & 1 deletion config/initializers/recommender_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@

#Settings for speed up TF-IDF calculations
config.max_text_length = (config.settings[:max_text_length].is_a?(Numeric) ? config.settings[:max_text_length] : 50)
config.repository_total_entries = [Lo.count,1].max
if ActiveRecord::Base.connection.table_exists?('los')
config.repository_total_entries = [Lo.count,1].max
else
config.repository_total_entries = 1
end

#Keep words in the configuration
words = {}
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# Config accesible in EuropeanaRS::Application::config

Rails.application.configure do
config.demo_user_available = (Rails.env==="development" and !User.where(:name => "Demo", :email => "[email protected]").first.nil?)
config.demo_user_available = (Rails.env==="development" and ActiveRecord::Base.connection.table_exists?('users') and !User.where(:name => "Demo", :email => "[email protected]").first.nil?)
end

0 comments on commit 97685ba

Please sign in to comment.