Code Monkey home page Code Monkey logo

wordcounter.solution's Introduction

Word Counter (C# Console Application)

A console-based application to count appearances of a word, where the user can search text for a target search word, hosted on GitHub. Last Updated 03.06.2020.

By Krista Rutz

Description

This application lets the user enter a phrase, sentence, or block of text and specify a search word, and calculates how many times this search word appears in the given text. This fully tested application can be set to return case sensitive or case-insensitive matches. It determines full word matching only, and can account for mid-word punctuation.

This functionality is attained using Char and String methods in vanilla C#, and without regular expressions. It utilizes custom RepeatCounter objects and overloaded constructors.

It is hosted on GitHub.

See this example output searching through a quote from Frank Herbert's Dune:

$dotnet run

Enter the text through which you wish to search:
“I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear. I will permit it to pass over me and through me. And when it has gone past I will turn the inner eye to see its path. Where the fear"

Enter the word you want to count:
fear

Case sensitive? [Y/N]
n

5 matches found
Press 'Enter' to perform a new search

Enter the text through which you wish to search:
“I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear. I will permit it to pass over me and through me. And when it has gone past I will turn the inner eye to see its path. Where the fear"

Enter the word you want to count:
fear

Case sensitive? [Y/N]
y

3 matches found

Installation / Set-up

Download or clone the repository to run this program locally! This program requires .NET Core SDK to run. Here is a free tutorial for installing .NET on Mac or Windows 10.

  • Download or clone this repo.
    • To Download ZIP:
      • Select "Download" on the GitHub Repository site
      • Once downloaded, open the ZIP and extract files. The new folder will be created as 'WordCounter.Solution'.
    • To Clone:
      • Clone from command line into your Desktop: $ git clone https://github.com/KristaRutz/WordCounter.Solution
      • The new directory will be created as 'Desktop/WordCounter.Solution'.
  • Once you have stored the files locally, execute the following commands.
    • Navigate to the application directory: $ cd WordCounter.Solution/WordCounter
    • dotnet build
    • dotnet run
  • Upon success, the program will begin running in your console.

Technologies Used

  • C#
  • .NET Core 2.2

Specs

Expand specs for this project
  • Spec: The file structure will be as shown:

    • Solution Name: WordCounter.Solution
    • ├──Project Name: WordCounter
    • └── Test Project Name: WordCounter.Tests
  • Spec: When viewing the project on GitHub, WordCounter, WordCounter.Tests, and README.md should be visible at the top level of the repository.

  • Spec: The following specs have tests associated with them.

  • Spec: There is a class called RepeatCounter.

  • Spec: The program collects an empty word input and checks how frequently that full word appears in an inputted sentence, then returns the number.

    • Input: "", "test"
    • Output: 0; // Not a word error.
  • Spec: The program collects a single word input and checks how frequently that full word appears in an empty string, then returns the number.

    • Input: "test", ""
    • Output: 0 matches;
  • Spec: The program collects a single word input and checks how frequently that full word appears in an inputted single word, then returns the number.

    • Input: "test", "test"
    • Output: 1;
  • Spec: The program collects a single word input and checks how frequently that full word appears in a string of only that word, then returns the number.

    • Input: "test", "test test test"
    • Output: 3;
  • Spec: The program collects a single word input and checks how frequently that full word appears in a string, then returns the number.

    • Input: "test", "this test is a test"
    • Output: 2;
  • Spec: The program checks for full word matches only (case sensitive).

    • Input: "test", "this test is still testing"
    • Output: 1;
  • Spec: The program can find words separated at spaces, beginning and end of string, or with punctuation attached.

    • Input: "test", "this test is a 'test.'"
    • Output: 2;
Expand user stories for this project
As a User-Type, I want... so that...
As a writer I want to know how many times I've typed a given word so that I can see the relative frequency of a given word
As an editor I want to know how often a word appears so that I can make sure to edit all mentions of the word
As the app developer I want the user to input whether or not the search is case-sensitive so that the user can be satisfied with their output

Known Bugs

  • No known bugs

Support and contact details

Please contact me if you run into any issues or have questions, ideas or concerns. I can be contacted at [email protected]. Feel free to create a pull request for updates - contributions to the code are encouraged!

License

Copyright (c) 2020 Krista Rutz

This software is licensed under the MIT license.

View license details

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

wordcounter.solution's People

Contributors

kristarutz avatar

Stargazers

 avatar

Watchers

James Cloos 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.