- Added Chinese character support to search engine and indexer thanks to Zhou
Xiaopeng.
This commit is contained in:
parent
6ad290ff63
commit
1845a3e1d5
4 changed files with 25 additions and 0 deletions
|
|
@ -270,6 +270,17 @@ sub search {
|
|||
unless ($keywords =~ m/"|\*/) { # do wildcards for people, like they'd expect
|
||||
my @terms = split(' ',$keywords);
|
||||
for (my $i = 0; $i < scalar(@terms); $i++) {
|
||||
#-------------- Edited by zxp for Chinese Word Segment
|
||||
utf8::decode($terms[$i]);
|
||||
my @segs = split /([A-z|\d]+|\S)/, $terms[$i];
|
||||
$terms[$i] = join " ",@segs;
|
||||
$terms[$i] =~ s/\s{2,}/ /g;
|
||||
$terms[$i] =~ s/(^\s|\s$)//g;
|
||||
$terms[$i] =~ s/\s/\'\'/g;
|
||||
if($terms[$i] =~ m/\'/) { # has non-latin latter in terms
|
||||
$terms[$i] = '"' . $terms[$i] . '"';
|
||||
}
|
||||
#-------------- Edited by zxp end
|
||||
$terms[$i] .= "*";
|
||||
}
|
||||
$keywords = join(" ", @terms);
|
||||
|
|
|
|||
|
|
@ -112,6 +112,16 @@ sub create {
|
|||
my $description = WebGUI::HTML::filter($asset->get('description'), "all");
|
||||
my $keywords = WebGUI::HTML::filter(join(" ",$asset->get("title"), $asset->get("menuTitle"), $asset->get("synopsis"), $url, $description), "all");
|
||||
my $synopsis = $asset->get("synopsis") || substr($description,0,255) || substr($keywords,0,255);
|
||||
|
||||
#-------------------- added by zxp for chinese word segment
|
||||
utf8::decode($keywords);
|
||||
my @segs = split /([A-z|\d]+|\S)/, $keywords;
|
||||
$keywords = join " ",@segs;
|
||||
$keywords =~ s/\s{2,}/ /g;
|
||||
$keywords =~ s/(^\s|\s$)//g;
|
||||
$keywords =~ s/\s/\'\'/g;
|
||||
#-------------------- added by zxp end
|
||||
|
||||
my $add = $self->session->db->prepare("insert into assetIndex (assetId, title, url, creationDate, revisionDate,
|
||||
ownerUserId, groupIdView, groupIdEdit, lineage, className, synopsis, keywords) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
|
||||
$add->execute([$asset->getId, $asset->get("title"), $asset->get("url"), $asset->get("creationDate"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue