PHP Chinese Word automatically get keyword introduction _php example

Source: Internet
Author: User
Tags require
Copy Code code as follows:

<?php
Header ("content-type:text/html; Charset=utf-8 ");
Define (' App_root ', str_replace (' \ \ ', '/', dirname (__file__));
$test = ' Here is a piece of Chinese test code! '
function Get_tags_arr ($title)
{
Require (app_root. ') /pscws4.class.php ');
$PSCWS = new PSCWS4 ();
$pscws->set_dict (app_root. ') /scws/dict.utf8.xdb ');
$pscws->set_rule (app_root. ') /scws/rules.utf8.ini ');
$pscws->set_ignore (TRUE);
$pscws->send_text ($title);
$words = $pscws->get_tops (5);
$tags = Array ();
foreach ($words as $val) {
$tags [] = $val [' word '];
}
$pscws->close ();
return $tags;
}
Print_r (Get_tags_arr ($test));
//============================================================
function Get_keywords_str ($content) {
Require (app_root. ') /phpanalysis.class.php ');
Phpanalysis:: $loadInit = false;
$pa = new Phpanalysis (' Utf-8 ', ' utf-8 ', false);
$pa->loaddict ();
$pa->setsource ($content);
$pa->startanalysis (FALSE);
$tags = $pa->getfinallyresult ();
return $tags;
}
Print (Get_keywords_str ($test));

Related Download Address

scws– Simple Chinese Word segmentation system

SCWS has no creative element in concept, the use of a self-collected word frequency dictionary, supplemented by a certain degree of proprietary names, names, geographical names, digital age, and other rules set, by a small range of testing probably accurate rate between 90% ~ 95%, has been able to basically meet some small and medium-sized search engines, keyword extraction and other occasions to use. Scws using pure C code development, with Unix-like OS as the main platform environment, providing a shared function library to facilitate the implantation of various existing software systems. In addition, it supports GBK,UTF-8,BIG5 and other encoding and has high efficiency in cutting words.

System platform: Windows/unix
Development language: C
How to use: PHP extension

Demo URL: http://www.ftphp.com/scws/demo.php
Open Source website: http://www.ftphp.com/scws/

Clear Maple Note: As a php extension, it is easy to integrate with existing Web systems based on PHP architecture, which is a big advantage.

phpanalysis-php Non-component word segmentation system

Phpanalysis Word segmentation system is based on string matching word segmentation method, this method is also called the machine segmentation method, it is according to a certain strategy of the Chinese character string to be analyzed with a "full large" machine Dictionary of the terms of the match, if found in the dictionary a string, then matching success (identify a word). According to the different scanning direction, the string matching segmentation method can be divided into forward matching and reverse matching. According to the case of different length preference, it can be divided into the maximum (longest) matching and the minimum (shortest) matching, according to whether or not the process of POS tagging, but also can be divided into simple word segmentation method and the combination of Word segmentation and annotation integration method.

System Platform: PHP Environment

Development language: PHP

How to use: HTTP service

Demo URL: http://www.itgrass.com/phpanalysis/
Open Source website: http://www.itgrass.com/phpanalysis/

Clear Maple Note: Simple to implement, easy to use, can do some simple application, but the large amount of data calculation efficiency is not as good as the previous several.

Try a few systems, the basic word segmentation function is no problem, but some of the differences in the division of some words there are some difference in the determination of part of speech, the system is different.

Http://www.jb51.net/codes/40139.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.