AI::Ca...lection(3pm)

πŸ“¦
version 0.09 Β· 2 versions
, in fedora 43

πŸ’– 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 the Files, SingleFile, or InMemory subclasses 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 that category_hash for 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 the stopwords parameter to the Document new() method. Iconic little handoff πŸŽ€
    • verbose β€” If it's true, some status/debugging info gets printed to STDOUT while 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 is AI::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 to next(). 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 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