Skip to content

Commit 35569a8

Browse files
committed
feat:The spec :matrix-result can be used instead of :vector-result.
fix:Correct handling of union case for .filter-by-profile().
1 parent 3d854c5 commit 35569a8

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

lib/ML/SparseMatrixRecommender.rakumod

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ class ML::SparseMatrixRecommender
446446
#| * C<$warn> Should warnings be issued or not?
447447
method profile($items is copy,
448448
Bool:D :$normalize = True,
449-
Bool:D :v(:$vector-result) = False,
449+
Bool:D :v(:matrix-result(:$vector-result)) = False,
450450
Bool:D :$warn = True) {
451451

452452
# Process $items
@@ -500,7 +500,7 @@ class ML::SparseMatrixRecommender
500500
Numeric:D $nrecs is copy = 12,
501501
Bool:D :$normalize = False,
502502
Bool:D :$remove-history = True,
503-
Bool:D :v(:$vector-result) = False,
503+
Bool:D :v(:matrix-result(:$vector-result)) = False,
504504
Bool:D :$warn = True) {
505505

506506
# Process $items
@@ -577,7 +577,7 @@ class ML::SparseMatrixRecommender
577577
method recommend-by-profile($tags is copy,
578578
Numeric:D $nrecs is copy = 12,
579579
Bool:D :$normalize = True,
580-
Bool:D :v(:$vector-result) = False,
580+
Bool:D :v(:matrix-result(:$vector-result)) = False,
581581
Bool:D :$warn = True) {
582582

583583
# Process $tags
@@ -646,30 +646,30 @@ class ML::SparseMatrixRecommender
646646
#| * C<$warn> Should warnings be issued or not?
647647
multi method filter-by-profile(Mix:D $prof,
648648
Str :$type = 'intersection',
649-
Bool :$object = True,
650-
Bool :$warn = True) {
651-
return self.filter-by-profile($prof.keys, :$type, :$object, :$warn);
649+
Bool :$warn = True,
650+
*%args) {
651+
return self.filter-by-profile($prof.keys, :$type, :$warn);
652652
}
653653

654654
multi method filter-by-profile(@prof,
655655
Str :$type = 'intersection',
656-
Bool :$object = True,
657-
Bool :$warn = True) {
656+
Bool :$warn = True,
657+
*%args) {
658658
my %profMix;
659659
if $type.lc eq 'intersection' {
660-
my $profileVec = self.to-profile-vector(@prof.Mix);
660+
my $profileVec = self.to-profile-vector(@prof.Mix, :$warn);
661661
my %sVec = self.take-M.unitize(:clone).dot($profileVec).row-sums(:pairs);
662662
# Number of non-zero elements of the profile vector
663663
my $n = $profileVec.column-sums.head;
664664
%profMix = %sVec.grep({ $_.value >= $n });
665665

666666
} elsif $type.lc eq 'union' {
667667

668-
%profMix = self.recommend-by-profile(@prof).take-value
668+
%profMix = self.recommend-by-profile(@prof, nrecs => Inf, :$warn).take-value
669669

670670
} else {
671671
note 'The value of the type argument is expected to be one of \'intersection\' or \'union\'.' if $warn;
672-
self.set-value(%());
672+
self.set-value(Whatever);
673673
return self;
674674
}
675675

0 commit comments

Comments
 (0)