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

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

πŸ’– AI::Categorizer::Category β€” a whole named category of docs, bestie πŸ’–

okay so this is AI::Categorizer::Category, a Perl module (that's the 3pm situation), and it is genuinely one of the chillest little classes you will ever meet. it's giving "i have one job and i do it beautifully." let's get into it 🫢


✨ NAME ✨

AI::Categorizer::Category β€” a named category of documents. that's it, that's the whole vibe. a name, and the docs that belong to it. iconic.


🌸 SYNOPSIS 🌸

here's how you actually use it, look:

my $category = AI::Categorizer::Category->by_name("sports");
my $name = $category->name;

my @docs = $category->documents;
my $num_docs = $category->documents;
my $features = $category->features;

$category->add_document($doc);
if ($category->contains_document($doc)) { ...

see how documents gives you a whole list in one context and just a count in the other?? that's called range and we love her for it πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so. this is a simple class β€” and i mean simple in the best way β€” that represents a named category which may contain zero or more documents. zero! could be empty! could be a whole pile! she's flexible like that.

but here's the thing you gotta know, and i'm saying it with my whole chest: each category is a "singleton" by name. so like, two Category objects with the same name should not be created at once. don't do it. that's not the move. one name, one object, periodt. πŸ’€


πŸŽ€ METHODS πŸŽ€

πŸ’œ new()

creates a new Category object and hands it right back to you. she accepts these parameters:

  • name β€” the name of this category. like, what is she called.
  • documents β€” a reference to an array of Document objects that should belong to this category. so you can just hand her the whole squad at once.

🧚 by_name(name => $string)

returns the Category object with the given name β€” or, if no such object exists yet, she just makes one for you. very "if you don't have one, bet, i'll handle it" energy. ✨

🌈 documents()

returns a list of the Document objects in this category in a list context, or the number of such objects in a scalar context. same method, different fits depending on what you asked for. main character behavior honestly.

⭐ features()

returns a FeatureVector object representing the sum of all the FeatureVectors of the Documents in this Category. yeah. she adds them all up. math but make it fashion. πŸ”₯

πŸ“ add_document($document)

informs the Category that the given Document belongs to it. like, "hey bestie, this one's yours now." that's it, that's the whole method.

πŸ’… contains_document($document)

returns true if the given document belongs to this category, or false otherwise. a simple yes or no. she's not gonna make it complicated for you.


πŸ‘‘ AUTHOR πŸ‘‘

Ken Williams, ken@mathforum.org β€” the legend, the icon, the moment.


Copyright 2000-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. free as in go wild, but, y'know, on Perl's terms. 🫢


🌈 SEE ALSO 🌈

go read those too, iykyk.


ngl, if you're out here making two Category objects with the same name at the same time, i'm not mad, i'm just disappointed. don't. πŸ™ˆ

and that's the whole page, bestie!! πŸŽ€ this one's from perl v5.42.0, dated 2025-07-25, and it lives in the User Contributed Perl Documentation section β€” so go forth, categorize your documents, and slay πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from