From a09a3a3be1f16b57cde6f1af4b90192234eef46f Mon Sep 17 00:00:00 2001 From: Jeff Yates Date: Sat, 24 Oct 2020 11:27:47 -0400 Subject: [PATCH] cleaned up comments --- sorter.rb | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/sorter.rb b/sorter.rb index 5a9e05e..5d62673 100755 --- a/sorter.rb +++ b/sorter.rb @@ -4,18 +4,16 @@ #More documentation TBD # #Current Usage: # # Scans a file for groups of words and counts the totals # -# Input file: ./tester.txt # -# Word group file: ./bins.json # -# Output file: ./output.json # +# Accepts the following options: # +# --file - the name of the text to sort # +# --type - iat or pn # +# --bin-file - the name of the bin csv file # # # # The input file is human readable, easy to edit. # # The output file is single-line JSON, use jq to format for reading. # # # #To Do: # -# * use STDIN to accept file to scan # -# * Support scanning multiple files # # * Output to csv # -# * Strip out header and footer text # ############################################################################ require 'json' require 'pp' @@ -63,6 +61,30 @@ def strip_text (text, start, fin) text.lines(start,chomp: true)[1].lines(fin,chomp: true)[0] end +#split_text expects: +# text - the text we're working on +# start - the starting string to search for +# fin the ending string to search for +# This method returns everything between start and fin and handles multiple sections +# Example: +# For the following text: +# > asdfasdf +# > AAAAA +# > testing +# > abcdefg +# > BBBBB +# > nothing +# > something +# > AAAAA +# > moo said the cow. +# > cluck said the chicken. +# > BBBBB +# > bark said the dog +# Running split_text(text, 'AAAAA', 'BBBBB') would return: +# > testing +# > abcdefg +# > moo said the cow. +# > cluck said the chicken. def split_text (text, start, fin) split1 = text.lines(start, chomp: true)[1..-1] split2 = []