<commit_before>/**
 * Copyright (c) 2008 <NAME>
 * All Rights Reserved.
 *
 * Name:          count
 *
 * Author:        <EMAIL> (WKR)
 * Creation Date: 11 November 2008
 *
 * Purpose:       Standard input line counter
 *
 * Description:
 *    count counts the number of unique lines on the standard input,
 *    outputting the counts after all the input is read.  The output
 *    of the program can be piped through sort -nr to sort it in order
 *    of descending frequency.
 *
 * Revision Information:
 *
 *    (WKR) 11 November 2008
 *          - Initial version.
 *
 * \file count.cpp
 */

#include <string>
#include <iostream>
#include <iomanip>
#include <map>
using namespace std;

int
main ( int    argc,
       char **argv )
{
    int             nNumLines = 0;
    map<string,int> LineDict;
    while ( cin.good() )
    {
        string sLine;
        getline ( cin, sLine );
        LineDict[sLine] += 1;
        nNumLines       += 1;
    }
    //int nWidth = 0;
    //while ( nNumLines > 0 )
    //{
    //    nWidth++;
    //    nNumLines /= 10;
    //}
    for ( map<string,int>::iterator iterator = LineDict.begin();
          iterator != LineDict.end(); iterator++ )
    {
        //cout << setw(nWidth) << iterator->second
        //         << "  " << iterator->first << endl;
        cout << iterator->second << "\t" << iterator->first << endl;
    }
    return 0;
}<commit_msg>count.cpp: include getopt and add -e option<commit_after>/**
 * Copyright (c) 2008 <NAME>
 * All Rights Reserved.
 *
 * Name:          count
 *
 * Author:        <EMAIL> (WKR)
 * Creation Date: 11 November 2008
 *
 * Purpose:       Standard input line counter
 *
 * Description:
 *    count counts the number of unique lines on the standard input,
 *    outputting the counts after all the input is read.  The output
 *    of the program can be piped through sort -nr to sort it in order
 *    of descending frequency.
 *
 * Revision Information:
 *
 *    (WKR) 11 November 2008
 *          - Initial version.
 *
 * \file count.cpp
 */

#include <unistd.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
using namespace std;

int
main ( int    argc,
       char **argv )
{
    bool       fIncludeLastLine = false;
    int        c;
    while ((c = getopt(argc, argv, "e?")) != -1)
    {
        switch(c)
        {
        case 'e':
            fIncludeLastLine = true;
            break;
        case '?':
            exit(1);
            break;
        default:
            break;
        }
    }

    int             nNumLines = 0;
    map<string,int> LineDict;
    while ( cin.good() )
    {
        string sLine;
        getline ( cin, sLine );
        if (fIncludeLastLine || !cin.eof() || sLine.length() != 0)
        {
            LineDict[sLine] += 1;
        }
        nNumLines       += 1;
    }
    //int nWidth = 0;
    //while ( nNumLines > 0 )
    //{
    //    nWidth++;
    //    nNumLines /= 10;
    //}
    for ( map<string,int>::iterator iterator = LineDict.begin();
          iterator != LineDict.end(); iterator++ )
    {
        //cout << setw(nWidth) << iterator->second
        //         << "  " << iterator->first << endl;
        cout << iterator->second << "\t" << iterator->first << endl;
    }
    return 0;
}
{'fraction_non_alphanumeric': 0.134886572654813, 'fraction_numerical': 0.015634580012262415, 'mean_word_length': 1.7841296928327646, 'pattern_counts': {'":': 0, '<': 56, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3330555', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1010, 'n_words': 303}