Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8198329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:55:44+00:00 2026-06-07T05:55:44+00:00

I have a Rails app with a database that has two columns (name and

  • 0

I have a Rails app with a database that has two columns (name and description). I would like to run a script that will find all unique words in either column, and rank them according to the frequency with which they occur. This is for the purpose of generating an index.

I understand that I will need to exclude certain words (such as “the” and “a”) and that the count may be imperfect because of pluralization. But I am happy to handle this manually in post processing, and am just looking for a basic script that will give me all of the words and their frequency.

Does anyone have any code that would do this or any guidance as to how to go about it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:55:45+00:00Added an answer on June 7, 2026 at 5:55 am
    def unique_word_count
      @thing = Thing.all
      @hash = Hash.new(0)
      @thing.each do |thing|
        name_array = thing.name.split(' ')
        description_array = thing.description.split(' ')
      end
      name_array.each do |word|
        @hash[word] += 1
      end
      description_array.each do |word|
        @hash[word] += 1
      end
    end
    

    I haven’t ran the code, but something like this is probably what you are looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Rails app that needs to expose values from a database as
I have a rails 3.2 app that uses 2 databases. One database is the
I have a standard Rails app that uses a database, sqlite3 and the webrick
We have the rails app, content served from the database. Now we need to
I have a very simple Rails app with a very simple relational database: Category
I have a Rails app that is served by Apache and Passenger, using only
I have a rails app, where Im having a drop box like feature-set. Each
Specifically, I have a number of pages in my Rails app that use the
I've got a Rails app that'll be sitting on top of a legacy database
I have a rails app that tracks membership cardholders, and needs to report on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.