Skip to content

A REST service which calculates frequency for characters in the input string

License

Notifications You must be signed in to change notification settings

akuniutka/character-frequency-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Character Frequency Calculator

A REST service which calculates character frequencies for an input string. Pass a JSON object with a string as the value of data property to the service, and it will respond with an array of JSON objects which consist of two properties each: character and frequency. The array will be sorted by frequency value in descending order.

Examples of an input string:

{
  "data": "Hello, World!"
}

and of the response to it:

[
  {
    "character": "l", 
    "frequency": 3
  }, 
  {
    "character": "o",
    "frequency": 2
  },
  {
    "character": " ",
    "frequency": 1
  },
  {
    "character": "!",
    "frequency": 1
  },
  {
    "character": ",",
    "frequency": 1
  },
  {
    "character": "H",
    "frequency": 1
  },
  {
    "character": "W",
    "frequency": 1
  },
  {
    "character": "d",
    "frequency": 1
  },
  {
    "character": "e",
    "frequency": 1
  },
  {
    "character": "r",
    "frequency": 1
  }
]

How to run

The project contains a script to build a Docker image directly from the GitHub repository, so you need only Dockerfile downloaded and Docker installed. Execute the following command to build an image:

docker build . -t character-frequency-calculator

Then start a container with the following command:

docker run -itd --rm -p 8080:8080 --name character-frequency-calculator character-frequency-calculator

When you finish, stop the container with the following command:

docker stop character-frequency-calculator

Endpoints

Description Endpoint
The service itself http://localhost:8080/calculateCharacterFrequencies
Spring Boot Actuator http://localhost:8080/actuator
Spring Boot Actuator Health http://localhost:8080/actuator/health
API documentation in JSON http://localhost:8080/v2/api-docs
API documentation in HTML http://localhost:8080/swagger-ui/

About

A REST service which calculates frequency for characters in the input string

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published