很多站长朋友们都不太清楚PHP进行英文分词,今天小编就来给大家整理PHP进行英文分词,希望对各位有所帮助,具体内容如下:
本文目录一览: 1、 求一个PHP的分词程序,比如我有一句话:我是个好学生,分词后: 我 是 一个 好 学生 谢谢 2、 php 分词,搜索引擎,技术 3、 php分词匹配 4、 PHP 如何实现按字数分割中英文混杂字符串成数组 5、 php中有什么函数能将字符串拆分成一个个的字(英语拆分成单词,汉字拆分成字,数字不拆分) 求一个PHP的分词程序,比如我有一句话:我是个好学生,分词后: 我 是 一个 好 学生 谢谢这个程序几乎是没有人能提供给你。为什么?
因为百度的翻译 其中就涉及到 语句分词,这是一个很高深的技术。而且还需要分词的词典,规则大概是包括所有汉字,分词规则,语句等等。
能做好这个技术,几千万都能卖出去。
php 分词,搜索引擎,技术你好,很高兴为你解答:
如果你仅仅是要把长句中的单词分出来,那是很简单的:
<?php
$str = "Google Translate for Business!";
$str = preg_replace("{\.|\,|\;|\:|\'|\"|\?|\!|\<|\>|\(|\)}", "", $str); // 移除所有标点符号
$arr = array_unique(explode(" ", $str)); // 以空格分割,并去重
var_dump($arr);
?>
以下是一段测试文本:
Instead of lots of commands to output HTML (as seen in C or Perl), PHP pages contain HTML with embedded code that does "something" (in this case, output "Hi, I'm a PHP script!"). The PHP code is enclosed in special start and end processing instructions <?php and ?> that allow you to jump into and out of "PHP mode."
What distinguishes PHP from something like client-side JavaScript is that the code is executed on the server, generating HTML which is then sent to the client. The client would receive the results of running that script, but would not know what the underlying code was. You can even configure your web server to process all your HTML files with PHP, and then there's really no way that users can tell what you have up your sleeve.
The best things in using PHP are that it is extremely simple for a newcomer, but offers many advanced features for a professional programmer. Don't be afraid reading the long list of PHP's features. You can jump in, in a short time, and start writing simple scripts in a few hours.
Although PHP's development is focused on server-side scripting, you can do much more with it. Read on, and see more in the What can PHP do? section, or go right to the introductory tutorial if you are only interested in web programming.
输出结果:
Instead, of, lots, commands, to, output, HTML, as, seen, in, C, or, Perl, PHP, pages, contain, with, embedded, code, that, does, something, this, case, Hi, Im, a, script, The, is, enclosed, special, start, and, end, processing, instructions, php, , allow, you, jump, into, out, mode What, distinguishes, from, like, client-side, JavaScript, the, executed, on, server, generating, which, then, sent, client, would, receive, results, running, but, not, know, what, underlying, was, You, can, even, configure, your, web, process, all, files, theres, really, no, way, users, tell, have, up, sleeve The, best, things, using, are, it, extremely, simple, for, newcomer, offers, many, advanced, features, professional, programmer, Dont, be, afraid, reading, long, list, PHPs, short, time, writing, scripts, few, hours Although, development, focused, server-side, scripting, do, much, more, Read, see, What, section, go, right, introductory, tutorial, if, only, interested, programming
使用sort()对其进行排序:
C, Dont, HTML, Hi, Im, Instead, JavaScript, PHP, PHPs, Perl, Read, The, What, You, a, advanced, afraid, all, allow, and, are, as, be, best, but, can, case, client, client-side, code, commands, configure, contain, development, distinguishes, do, does, embedded, enclosed, end, even, executed, extremely, features, few, files, focused, for, from, generating, go, have, hours Although, if, in, instructions, interested, into, introductory, is, it, jump, know, like, list, long, lots, many, mode What, more, much, newcomer, no, not, of, offers, on, only, or, out, output, pages, php, process, processing, professional, programmer, programming, reading, really, receive, results, right, running, script, scripting, scripts, section, see, seen, sent, server, server-side, short, simple, sleeve The, something, special, start, tell, that, the, then, theres, things, this, time, to, tutorial, underlying, up, users, using, was, way, web, what, which, with, would, writing, you, your
-----------------------------------
如有疑问欢迎追问!
满意请点击右上方【选为满意回答】按钮么么哒 o(∩_∩)o
php分词匹配sphinx 只是提供中文的全文索引支持.
还需要一个分词扩展提供分词功能. 可以试试 phpcws
PHP 如何实现按字数分割中英文混杂字符串成数组以下是我编写的代码,实现对中英文混杂字符进行分割:
<?php
function mbStrSplit ($string, $len=1) {
$start = 0;
$strlen = mb_strlen($string);
while ($strlen) {
$array[] = mb_substr($string,$start,$len,"utf8");
$string = mb_substr($string, $len, $strlen,"utf8");
$strlen = mb_strlen($string);
}
return $array;
}
header('Content-type:text/html;charset=utf-8');
$str = '我爱北京3我爱上海-我爱xianggang';
$r = mbStrSplit($str, 4);
echo '<pre>';
print_r($r);
echo '</pre>';
?>
运行结果:
Array
(
[0] => 我爱北京
[1] => 3我爱上
[2] => 海-我爱
[3] => xian
[4] => ggan
[5] => g
)
php中有什么函数能将字符串拆分成一个个的字(英语拆分成单词,汉字拆分成字,数字不拆分)PHP函数中好像不能拆分汉字,拆分汉字需要把他们分组后组成数组输出
关于PHP进行英文分词的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。
查看更多关于PHP进行英文分词 php分词技术的详细内容...