Giter Club home page Giter Club logo

text-analyzer's Introduction

Describe: wordCounter()

Test: "It should return 1 if a passage has just one word." Code: const text = "hello"; wordCounter(text); Expected Output: 1

Test: "It should return 2 if a passage has two words." Code: const text = "hello there"; wordCounter(text); Expected Output: 2

Test: "It should return 0 for an empty string." Code: wordCounter(""); Expected Output: 0

Test: "It should not count numbers as words." Code: wordCounter("hi there 77 19"); Expected Output: 2

Describe: numberOfOccurrencesInText()

Test: "It should return 0 occurrences of a word for an empty string." Code: const text = ""; const word = "red"; numberOfOccurrencesInText(word, text); Expected Output: 0

Test: "It should return 1 occurrence of a word when the word and the text are the same." Code: const text = "red"; const word = "red"; numberOfOccurrencesInText(word, text); Expected Output: 1

Test: "It should return 0 occurrences of a word when the word and the text are different." Code: const text = "red"; const word = "blue"; numberOfOccurrencesInText(word, text); Expected Output: 0

Test: "It should return the number of occurrences of a word." Code: const text = "red blue red red red green"; const word = "red"; numberOfOccurrencesInText(word, text); Expected Output: 4

Test: "It should return a word match regardless of case." Code: const text = "red RED Red green Green GREEN"; const word = "Red"; numberOfOccurrencesInText(word, text); Expected Output: 3

Test: "It should return a word match regardless of punctuation." Code: const text = "Red! Red. I like red, green, and yellow."; const word = "Red"; numberOfOccurrencesInText(word, text); Expected Output: 3

Test: "If an empty string is passed in as a word, it should return 0." Code: const word = ""; const text = "red RED Red!"; wordCounter(word, text); Expected Output: 0

Describe: boldPassage()

Test: "It should return a non-matching word in a p tag." Code: const word = "hello"; const text = "yo"; boldPassage(word, text); Expected Output: "

yo

"

Test: "It should return a matching word in a b tag." Code: const word = "hello"; const text = "hello"; boldPassage(word, text); Expected Output: "

hello

"

Test: "It should wrap words that match in b tags but not words that don't." Code: const word = "hello"; const text = "hello there"; boldPassage(word, text); Expected Output: "

hello there

"

Describe: mostUsedWords()

Test: "It should return the words in the passage sorted alphabetically." Code: const passage = "What are you doing today" mostUsedWords(text); Expected Output: "are, doing, today, what, you"

Test: "It should return the number of times each word occurs." Code: const passage = "What am am am I I doing today?" mostUsedWords(text); Expected Output: [[3, am],[1, doing],[2, i],[1, today],[1, what]]

Test: "It should return the number of times each word occurs in order, most to least." Code: const passage = "What am am am I I doing today?" mostUsedWords(text); Expected Output: [[3, am],[2, i],[1, doing],[1, today],[1, what]]

Describe: omitOffensiveWords()

Test: "It should return a boolean whether offensive words as defined are present." Code: const passage = "What are you doing today, you zoinks, muppeteer, biffaroni, loopdaloop!" omitOffensiveWords() Expected Output: true

Test: "It should not return any offensive words as defined." Code: const passage = "What are you doing today, you zoinks, muppeteer, biffaroni, loopdaloop!" omitOffensiveWords(text); Expected Output: "What are you doing today, you"

text-analyzer's People

Contributors

rjashby avatar

Watchers

 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.