Giter VIP home page Giter VIP logo

stringfinder's Introduction

#String Finder

Requires PHP 5.4 or greater. CLI PHP Program that reads a CSV file as input and outputs the strings that appear as a pair on the same line of the CSV. The output is based on a threshold set on the first line of the CSV.

Input Format The first line contains an integer, the minimum number of co-occurrences/threshold for a pair of strings to appear in the output. Subsequent lines are comma-separated lists of strings.

Output Pairs of strings, separated by a comma, that appeared together on at least the threshold number of lines in the input. A pair will appear exactly once, and the pair of strings will be listed in alphabetical order.

Example Input
3
Orange,Apple,Banana
Pear,Pineapple,Banana
Orange,Apple,Avocado
Cherry,Pineapple,Apple,Avocado,Lemon
Pear,Cherry,Avocado
Pear,Cherry,Orange,Lemon,Banana
Orange,Apple,Avocado
Pineapple,Apple,Avocado
Pear,Cherry,Orange
Pear,Orange,Lemon

Example Output
Apple,Avocado
Apple,Orange
Cherry,Pear
Orange,Pear

Example Explanation Since the first line of the input reads, 3, the output must only show those strings which appear together in a at least 3 lines of the file. There are exactly 4 pairs of strings that appear together at least 3 times in the input.

To run from terminal:

php stringFinder_controller.php < input_file.txt

stringfinder's People

Contributors

gbarnett374 avatar

Watchers

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