CodeButcher
Programmer
Longtime programmer, first time perl'er.
I have the following code that i'm trying to convert from Perl to C#.
I don't understand the following lines:
1.) my $vector = zeroes $self->{'word_count'};
my guess is that it initializes a vector to have the same number of items as word_count array with values set to 0. Is that right?
2.) my $offset = $self->{'word_index'}->{$w};
My guess is that it's pulling the value of the hash word_index at position or key value of $w. Is that right?
I have the following code that i'm trying to convert from Perl to C#.
Code:
sub make_vector {
my ( $self, $doc ) = @_;
my %words = $self->get_words( $doc );
my $vector = zeroes $self->{'word_count'};
foreach my $w ( keys %words ) {
my $value = $words{$w};
my $offset = $self->{'word_index'}->{$w};
index( $vector, $offset ) .= $value;
}
return $vector;
}
I don't understand the following lines:
1.) my $vector = zeroes $self->{'word_count'};
my guess is that it initializes a vector to have the same number of items as word_count array with values set to 0. Is that right?
2.) my $offset = $self->{'word_index'}->{$w};
My guess is that it's pulling the value of the hash word_index at position or key value of $w. Is that right?