Ejemplo n.º 1
0
Archivo: span.cpp Proyecto: mazonka/w
int show(int ac, const char ** av, std::vector<Summary> * sum)
{
    int level = 1;
    if ( ac > 1 ) level = std::atoi(av[1]);

    cout <<  "\nFluency Bad     Need    New     Old     When     Name\n";
    cout <<    "=====================================================\n";

    Show data;

    WordCount wc;
    showr(".", data, level, sum, &wc);
    cout <<    "-----------------------------------------------------\n";
    output_les_stat(data.st, data.flue);
    cout << '\n';

    cout << '\n' << wc.str() << '\n';

    return 0;
}
Ejemplo n.º 2
0
Archivo: span.cpp Proyecto: mazonka/w
int wordc(int ac, const char ** av)
{
    if (ac < 2)
    {
        cout << "Use: -wc {srt or txt file}\n";
        cout << "word count statistics\n";
        return 1;
    }

    string fi = av[1];

    bool srt = false;

    try
    {
        int sz = fi.size();
        if ( sz < 5 ) throw 1;
        if ( fi.substr(sz - 4) == ".srt" ) srt = true;
    }
    catch (int)
    {
        throw "Input file must be .srt or .txt";
    }

    cout << "Input     : " << fi << '\n';

    WordCount wc;
    if (srt)
    {
        Lesson si(fi, true, true);
        wc = si.wordcount();
    }
    else
    {
        wc = wordcount(gl::file2str(fi));
    }

    cout << wc.str() << '\n';

    return 0;
}