Giter Club home page Giter Club logo

language's Introduction

Natural Language Statistics

Build Status Go Report Card GoDoc

Get

$ go get github.com/jamesjoshuahill/language

Run

$ language                                             # Start server
$ echo "here are some more words" | nc localhost 5555  # Send some language
$ curl http://localhost:8080/stats                     # Request language stats
{"count":5,"top5words":["some","more","words","here","are"],"top5letters":["s","o","e","r","m"]}

The server can be configured with flags:

$ language -h  # Outputs usage

Test

The test suite uses Ginkgo and Gomega and can be run with go test, or using the ginkgo CLI:

$ cd $GOPATH/src/github.com/jamesjoshuahill/language
$ go get github.com/onsi/ginkgo/ginkgo
$ go get github.com/onsi/gomega
$ ginkgo -r -randomizeSuites -randomizeAllSpecs -cover

Exercise

Build a simple Go application. When started, it will listen on port 5555 (but this may be configurable through a command-line flag). Clients will be able to connect to this port and send arbitrary natural language over the wire. The purpose of the application is to process the text, and store some stats about the different words that it sees.

The application will also expose an HTTP interface on port 8080 (configurable): clients hitting the /stats endpoint will receive a JSON representation of the statistics about the words that the application has seen so far.

Specifically, the JSON response should look like:

{
  "count": 42,
  "top5words": ["lorem", "ipsum", "dolor", "sit", "amet"],
  "top5letters": ["e", "t", "a", "o", "i"]
}

Where "count" represents the total number of words seen, "top5words" contains the 5 words that have been seen with the highest frequency, and "top5letters" contains the 5 letters that have been seen with the highest frequency (you may choose to transform all letters to lowercase if you so wish).

A few things to look out for:

  • The number of words to process may be large, although you may safely assume that they will fit within main memory.
  • The application should support a high degree of concurrency, whereby many clients would be sending text at the same time.
  • While we only expect three metrics over the collection of words, you should assume that a more fully-fledged version of the application would be collecting many more of these.
  • We would like to see your approach to automated testing for this type of Go program.

language's People

Watchers

James Cloos avatar Josh Hill 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.