AI::Ca...lection(3pm)
π NAME π
AI::Categorizer::Collection β bestie, this is how you access your stored documents β¨
πΈ SYNOPSIS πΈ
my $c = new AI::Categorizer::Collection::Files
(path => '/tmp/docs/training',
category_file => '/tmp/docs/cats.txt');
print "Total number of docs: ", $c->count_documents, "\n";
while (my $document = $c->next) {
...
}
$c->rewind; # For further operations
π¦ DESCRIPTION π¦
Okay so picture this: this is an abstract class, and what it does is implement an iterator for getting at your documents in whatever format they're natively stored in. It's giving very much "the blueprint, not the building" π
Lowkey important: you cannot directly create an instance of the Collection class, because it is abstract. No cap. If you want a concrete interface, go read the docs for theFiles,SingleFile, orInMemorysubclasses instead. That's where the actual vibes live π«Ά
β¨ METHODS β¨
new()β Creates a new Collection object and hands it right back to you, slay. It accepts these parameters:category_hashβ This one's a reference to a hash that maps document names over to category names. The keys of the hash are the document names, and each value should be a reference to an array holding the names of the categories that document belongs to. So like, name β‘οΈ list of cats, iykyk π±category_fileβ Points at a file that gets read in to build thatcategory_hashfor you. Every line of the file should list one document's name, then a list of category names, and everything is separated by whitespace. Space-separated, bestie, don't get cute with commas πstopword_fileβ Specifies a file containing a list of "stopwords", aka words that should automatically be disregarded when scanning/reading documents. One word per line, please and thank you. The file gets parsed, and then it's fed as thestopwordsparameter to the Documentnew()method. Iconic little handoff πverboseβ If it's true, some status/debugging info gets printed toSTDOUTwhile stuff is running. Perfect for when you're nosy and want to see what's happening πdocument_classβ The class that says what type of Document object should get created. This generally specifies the format your documents are stored in. The default isAI::Categorizer::Document::Textβ
next()β Returns the next Document object in the Collection. Just keeps handing you the next one, one at a time πrewind()β Resets the iterator so you can make further calls tonext(). It's the rewind button, fr fr βͺcount_documents()β Returns the total number of documents in the Collection. Heads up though: this usually resets the iterator π And that's because it may not be possible to resume iterating where we left off. So yeah, count and rewind kinda come as a package deal, be aware π
π AUTHOR π
Ken Williams, ken@mathforum.org
π COPYRIGHT π
Copyright 2002-2003 Ken Williams. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
π₯ SEE ALSO π₯
AI::Categorizer(3), Storable(3)
And that's a wrap, bestie!! This page was living in perl v5.42.0, dated 2025-07-25 β go forth and categorize, you absolute main character π β¨π«Ά
π¦ where this page comes from
- fedora 43: perl-AI-Categorizer 0.09-38.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms