AI::Ca...ategory(3pm)
π 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 ofDocumentobjects 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 π
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
- 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