Giter Site home page Giter Site logo

wdi_1_ruby_hw_word_methods's Introduction

Alice Analysis

"Curiouser and curiouser!"

This assignment is an exercise in writing and combining your own methods, and looking up documentation on some of Ruby's built-in methods. In sample.txt you will find the first chapter of Alice's Adventures in Wonderland in plain text format โ€“ your goal is to write several methods to analyze this text. analysis.rb contains a line that will load the text into a Ruby string to get you started.

Specifications

These methods are listed in the order we suggest you write them, but it's possible to skip around a bit.

  1. Method that splits a string (e.g. the text from sample.txt) into an array of normalized words. "Normalized" here means that the words should be all lowercase and scrubbed of any punctuation such as periods or parentheses.

  2. Method that takes a string and returns an array of all unique words in it, ignoring punctuation and capitalization differences.

  3. Method that counts how many words are in a string. This method should also provide the option to count unique words instead of total words.

  4. Method that takes a string and returns a hash where the keys are normalized words, and the values are integers representing how many times that word occurs in the string.

  5. Method that finds the most common word in a string that is longer than a particular "length threshold". The threshold should be optional, and default to 3 characters (i.e. words of 3 characters or less will not be considered). It's up to you how to handle multiple words being "tied" for most common.

Make sure you are combining methods wherever possible to avoid duplication of code! Your methods should also be named appropriately based on the data they return. And of course, your code should use correct indentation/style and descriptive variable names.

Extra Challenges

  • Write a method that finds the length of the longest word in a string, and returns an array of all unique words in the string that are that length.

wdi_1_ruby_hw_word_methods's People

Contributors

grantovich avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.