⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sloppy.pm

📁 Plucene-1.25.tar.gz PERL版本的lucene
💻 PM
字号:
package Plucene::Search::PhraseScorer::Sloppy;=head1 NAMEPlucene::Search::PhraseScorer::Sloppy - sloppy phrase scorer=head1 SYNOPSIS	# isa Plucene::Search::PhraseScorer=head1 DESCRIPTIONThis is a sloppy phrase scorer=head1 METHODS=cutuse strict;use warnings;use List::Util qw(max);use base 'Plucene::Search::PhraseScorer';__PACKAGE__->mk_accessors(q{slop});sub _phrase_freq {	my $self = shift;	my $end  = 0;	$#{ $self->{pq} } = -1;	my $pp = $self->first;	while ($pp) {		$pp->first_position;		$end = max($end, $pp->position);		push @{ $self->{pq} }, $pp;		$pp = $pp->next_in_list;	}	my $freq = 0;	my $done = 0;	do {		my $pp    = shift @{ $self->{pq} };		my $start = $pp->position;		my $next  = $self->{pq}->[0]->position;		for (my $pos = $start ; $pos <= $next ; $pos = $pp->position) {			$start = $pos;			if (!$pp->next_position) {				$done = 1;				last;			}		}		my $length = $end - $start;		$freq += 1 / ($length + 1) if $length <= $self->slop;		$end = max($end, $pp->position);		push @{ $self->{pq} }, $pp;	} while (!$done);	return $freq;}1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -