HUGE-COUNT(1)
π huge-count(1) / huge-count.pl π
okay so this is the huge-count(1) page from the User Contributed Perl Documentation for huge-count.pl, and it's giving βcount all the bigrams in a huge text without using huge amounts of memoryβ main-character energy. bestie, we're covering every flag and every caveat, no skips, no cap. π«Ά
πΈ NAME πΈ
huge-count.pl β count all the bigrams in a huge text without using huge amounts of memory. literally the whole point. π
β¨ SYNOPSIS β¨
huge-count.pl --tokenlist --split 100 destination-dir input
π DESCRIPTION π
Runs count.pl efficiently on large amounts of data by splitting the data into separate files, and counting up each file separately, and then merging them to get overall results. it's giving divide-and-conquer but make it bigram. π
Two output files are created:
destination-dir/huge-count.outputcontains the bigram counts after applying--removeand--remove. (yes, the double--removeis literally what this page says β I'm not editing the lore π)destination-dir/complete-huge-count.outputprovides the bigram counts as if no--uremoveor--removecutoff were provided.
π USAGE π
huge-count.pl [OPTIONS] DESTINATION [SOURCE]+
π¦ INPUT π¦
Required Arguments:
[SOURCE]+β input tohuge-count.plshould be a -- Single plain text file Or
- Single flat directory containing multiple plain text files Or
- List of multiple plain text files
DESTINATIONβ a complete path to a writable directory to whichhuge-count.plcan write all intermediate and final output files. IfDESTINATIONdoes not exist, a new directory is created, otherwise, the current directory is simply used for writing the output files.
β οΈ NOTE: IfDESTINATIONalready exists and if the names of some of the existing files inDESTINATIONclash with the names of the output files created by huge-count, these files will be over-written w/o prompting user. so yeah, guard your faves. π
--tokenlistβ this parameter is required. huge-count will callcount.pland print out all the bigramscount.plcan find out.
Optional Arguments:
--split Nβ this parameter is required. huge-count will divide the output bigrams tokenlist generated bycount.pl, sort on each part and recombine the bigram counts from all these intermediate result files into a single bigram output that shows bigram counts inSOURCE.
Each part created with --split N will contain N lines. Value of N should be chosen such that huge-sort.pl can be efficiently run on any part containing N lines from the file contains all bigrams file.
We suggest that N is equal to the number of KB of memory you have. If the computer has 8 GB RAM, which is 8,000,000 KB, N should be set to 8000000. If N is set too small, split output file suffixes exhausted. π
--token TOKENFILEβ specify a file containing Perl regular expressions that define the tokenization scheme for counting. This will be provided tocount.pl's--tokenoption.--nontoken NOTOKENFILEβ specify a file containing Perl regular expressions of non-token sequences that are removed prior to tokenization. This will be provided to thecount.pl's--nontokenoption.--stop STOPFILEβ specify a file of Perl regex/s containing the list of stop words to be omitted from the output BIGRAMS. Stop list can be used in two modes -- AND mode declared with
@stop.mode = ANDon the 1st line of theSTOPFILE - OR mode declared using
@stop.mode = ORon the 1st line of theSTOPFILE.
- AND mode declared with
In AND mode, bigrams whose both constituent words are stop words are removed while, in OR mode, bigrams whose either or both constituent words are stopwords are removed from the output.
--window Wβ tokens appearing withinWpositions from each other (with at mostW-2intervening words) will form bigrams. Same ascount.pl's--windowoption.--remove Lβ bigrams with counts less thanLin the entireSOURCEdata are removed from the sample. The counts of the removed bigrams are not counted in any marginal totals. This has same effect ascount.pl's--removeoption.--uremove Lβ bigrams with counts more thanLin the entireSOURCEdata are removed from the sample. The counts of the removed bigrams are not counted in any marginal totals. This has same effect ascount.pl's--uremoveoption.--frequency Fβ bigrams with counts less thanFin the entireSOURCEare not displayed. The counts of the skipped bigrams ARE counted in the marginal totals. In other words,--frequencyinhuge-count.plhas same effect as thecount.pl's--frequencyoption.--ufrequency Fβ bigrams with counts more thanFin the entireSOURCEare not displayed. The counts of the skipped bigrams ARE counted in the marginal totals. In other words,--frequencyinhuge-count.plhas same effect as thecount.pl's--ufrequencyoption. (again, that's the page's wording, bestie β--frequencyis sitting right there in the sentence π)--newLineβ switches ON the--newLineoption incount.pl. This will prevent bigrams from spanning across the lines.
Other Options :
--helpβ displays this message.--versionβ displays the version information.
π§ PROGRAM LOGIC π§
- STEP 1
# create output dir
if(!-e DESTINATION) then
mkdir DESTINATION;
- STEP 2
- If
SOURCEis a single plain file -huge-count.plwith--tokenlistoption callcount.pland run on the single plain file and print out all bigrams into one file. The count outputs are also created inDESTINATION. SOURCEis a single flat directory containing multiple plain files -huge-count.plwith--tokenlistoption callcount.pland run on each file present in theSOURCEdirectory. All files inSOURCEare treated as the data files. IfSOURCEcontains sub-directories, these are simply skipped. Intermediate bigram outputs are written inDESTINATION.SOURCEis a list of multiple plain files - If#arg > 2, all arguments specified after the first argument are considered as theSOURCEfile names.count.plis separately run on each of theSOURCEfiles specified byargv[1],argv[2], ...argv[n](skippingargv[0]which should beDESTINATION). Intermediate results are created inDESTINATION.
- If
In summary, a large datafile can be provided to huge-count in the form of
a. A single plain file b. A directory containing several plain files c. Multiple plain files directly specified as command line arguments
In all these cases, count.pl with --tokenlist is separately run on SOURCE files or parts of SOURCE file and intermediate results are written in DESTINATION dir.
- STEP 3 β split the output file generate by
count.plwith--tokenlistinto smaller files by the number of bigramsN. - STEP 4 β
huge-sort.plcounts the unique bigrams and sort them in alphabetic order. - STEP 5 β
huge-merge.plmerge the bigrams of each sorted bigrams file.
π OUTPUT π
After huge-count finishes successfully, DESTINATION will contain -
- Final bigram count file (
huge-count.output) showing bigram counts in the entireSOURCEafter--removeand--uremoveapplied. - Final bigram count file (
complete-huge-count.output) showing bigram counts in the entireSOURCEwithout--removeand--uremove.
π BUGS π
huge-count.pl doesn't consider bigrams at file boundaries. In other words, the result of count.pl and huge-count.pl on the same data file will differ if --newLine is not used, in that, huge-count.pl runs count.pl on multiple files separately and thus looses the track of the bigrams on file boundaries. With --window not specified, there will be loss of one bigram at each file boundary while its W bigrams with --window W.
Functionality of huge-count with --tokenlist is same as count only if --newLine is used and all files start and end on sentence boundaries. In other words, there should not be any sentence breaks at the start or end of any file given to huge-count.
π AUTHOR π
- Amruta Purandare, University of Minnesota, Duluth
- Ted Pedersen, University of Minnesota, Duluth tpederse at umn.edu
- Ying Liu, University of Minnesota, Twin Cities liux0395 at umn.edu
π COPYRIGHT π
Copyright (c) 2004-2010, Amruta Purandare, Ted Pedersen, and Ying Liu
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to
The Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.
okay that's the whole page, bestie π source/version perl v5.42.3, date 2015-10-04, and it's the HUGE-COUNT(1) page. slay and protect your DESTINATION files. π
π¦ where this page comes from
- nixos 26.05: perl5.42.3-Text-NSP 1.31
- nixpkgs unstable: perl5.42.3-Text-NSP 1.31
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms