itplato / phpanalysis
php chinese analysis, It's component-free word segmentation in language-php
Installs: 115
Dependents: 0
Suggesters: 0
Security: 0
Stars: 13
Watchers: 1
Forks: 8
Open Issues: 0
Language:TSQL
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-05-13 09:01:14 UTC
README
一、最新变化
1、修改源文件结构支持composer 2、把切分同时优化的操作模式改为独立步骤操作(即是粗分、切分、优化三步完全独立) 3、修改类成员调用支持自身引用,即是 xx()->xx()->xx() 模式
二、一个基本的分词操作
use Tutu\PhpAnalysis; header('content-type:text/html;charset=utf-8'); $result_str = PhpAnalysis::Instance() ->SetSource("composer的出现真是让人们眼前一亮,web开发从此变成了一件很『好玩』的事情。") ->Delimiter(' ') ->ExecSimpleAnalysis() ->ExecDeepAnalysis() ->Optimize( true ); echo $result_str; 如果用默认参数,上面也可以简化为: $result_str = PhpAnalysis::Instance() ->SetSource("composer的出现真是让人们眼前一亮,web开发从此变成了一件很『好玩』的事情。") ->Exec();
三、常用设置及方法
- Instance( $force_init = false )
- SetOptions($unit_special_word=true, $unit_single_word=false, $max_split=false, $high_freq_priority=false, $optimize=true)
- SetSource($source, $source_encoding = 'utf-8', $target_encoding='utf-8')
- Delimiter( $str )
- Exec( $return = true )
- LoadDict( $main_dic_file = '' )
- AssistBuildDict( $source_file, $target_file='' )
- AssistExportDict( $target_file, $dicfile = '' )
- AssistGetCompare()
- AssistGetDeep()
- AssistGetSimple( $string=true )
- GetNewWords( $is_array=false )
- GetResult()
- GetResultProperty()
- GetTags( $num = 10, $with_rank = false )