in reply to Re^2: RFC - Documentation Review
in thread Please review documentation of my AI::Embedding module
I feel the term 'comparator' is unclear. But I cannot think of a better one!
I have no problem with the name, only with the interface - it doesn't make sense (as far as I can see) to embed the comparator within the object. Apart from anything else that makes it harder to have multiple comparators, for no obvious benefit.
I'm imagining a simple curry like:
sub comparator { my($self, $embed) = @_; return sub { $self->compare($embed, @_); }; }
.. and documentation like:
comparator
my $comparator = $embedding->comparator($csv_embedding1); ... my $comparison = $comparator->($csv_embedding2);Returns a subroutine reference that can be used for repeated compare calls for the given vector against different secondary vectors, that returns the same type of result as compare.
Update: I forgot to include the extra work for comparator, it should probably look more like:
sub comparator { my($self, $embed) = @_; my $vector1 = $self->_make_vector($embed); return sub { my($embed2) = @_; my $vector2 = $self->_make_vector($embed2); return $self->_compare_vector($vector1, $vector2); }; }
.. where _compare_vector would be factored out of the last 9 lines of compare.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: RFC - Documentation Review
by Bod (Parson) on Jun 03, 2023 at 11:31 UTC | |
by hv (Prior) on Jun 03, 2023 at 14:12 UTC | |
by afoken (Chancellor) on Jun 03, 2023 at 12:23 UTC |