Lucy::...exicon(3pm)
💖 Lucy::Index::Lexicon 💖
okay bestie, so this is Lucy::Index::Lexicon — a page from the User Contributed Perl Documentation collection, and it's literally about iterating over a field's terms. no cap, it's giving "the most organized girl in the group chat" energy. let's get into it 🎀
✨ NAME ✨
Lucy::Index::Lexicon — Iterator for a field’s terms. 💅
✨ SYNOPSIS ✨
my $lex_reader = $seg_reader->obtain('Lucy::Index::LexiconReader');
my $lexicon = $lex_reader->lexicon( field => 'content' );
while ( $lexicon->next ) {
print $lexicon->get_term . "\n";
}
see how clean that is?? you grab a lexicon reader, you ask it for a lexicon for the 'content' field, and then you just keep calling next until it stops being true. iconic behavior honestly. ✨
✨ DESCRIPTION ✨
so a Lexicon is an iterator, right? and what it does is hand you every single unique term for a given field — but in sorted order. like, alphabetically. it does not come at you in chaos order, it comes at you in sorted order. we love a girl with a system. 👑
okay so imagine your index has two documents, and both of them have a 'content' field. one holds “three blind mice” and the other holds “three musketeers”. if you iterate through the 'content' field’s lexicon, this is the list you get:
blind
mice
musketeers
three
see?? unique terms only (so three shows up once, not twice, even though it's in both docs 💀) and sorted. the lexicon really said "duplicates are not the vibe." 🌸
✨ ABSTRACT METHODS ✨
these are abstract, bestie — you don't call them on the base class, you get them from an actual lexicon reader. iykyk 🦋
🌈 seek
$lexicon->seek($target);
$lexicon->seek(); # default: undef
seek the Lexicon to the first iterator state which is greater than or equal to "target". so it jumps you forward to the first thing that's >= your target. and if "target" is undef, it resets the iterator. no target, fresh start, main character reset arc. ✨
🌈 next
my $bool = $lexicon->next();
proceed to the next term. that's it, that's the whole job. 🫶
Returns: true until the iterator is exhausted, then false.
🌈 reset
$lexicon->reset();
reset the iterator. but listen — next() must be called to proceed to the first element. like, reset puts you before the start line, not on the first term. so don't skip the next(), babe, or you'll be standing there like 👁️👄👁️
🌈 get_term
my $obj = $lexicon->get_term();
return the current term — or undef if the iterator is not in a valid state. so if you're off the rails or before you've started, you get undef. vibe check failed, no term for you. 🙈
✨ INHERITANCE ✨
Lucy::Index::Lexicon isa Clownfish::Obj. so yeah, it's part of the Clownfish family tree. family reunion energy. 🌈
and that's the whole page, bestie!! no notes, ate it up, left zero crumbs. 🍓
this has been brought to you by perl v5.42.0, dated 2025-07-25 💖✨🎀🦋🌸
📦 where this page comes from
- fedora 43: perl-Lucy 0.6.2-26.fc43 · Apache-2.0 AND MIT AND Unicode-DFS-2015
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms