Documentation
¶
Index ¶
- Constants
- type Scws
- func (this *Scws) AddDict(fPath string, mode int) error
- func (this *Scws) Free() error
- func (this *Scws) Init(count int) error
- func (this *Scws) Segment(text string) ([]ScwsRes, error)
- func (this *Scws) SetCharset(cs string)
- func (this *Scws) SetDict(fPath string, mode int) error
- func (this *Scws) SetDuality(yes int)
- func (this *Scws) SetIgnore(yes int)
- func (this *Scws) SetMulti(mode int)
- func (this *Scws) SetRule(fPath string) error
- type ScwsRes
Constants ¶
View Source
const ( // SetMulti mode SCWS_MULTI_SHORT = C.SCWS_MULTI_SHORT SCWS_MULTI_DUALITY = C.SCWS_MULTI_DUALITY SCWS_MULTI_ZMAIN = C.SCWS_MULTI_ZMAIN SCWS_MULTI_ZALL = C.SCWS_MULTI_ZALL // SetDict/AddDict mode SCWS_XDICT_TXT = C.SCWS_XDICT_TXT SCWS_XDICT_XDB = C.SCWS_XDICT_XDB SCWS_XDICT_MEM = C.SCWS_XDICT_MEM )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Scws ¶
type Scws struct {
// contains filtered or unexported fields
}
Scws是封装好的切词服务.提供一个简单的切词接口.
func (*Scws) AddDict ¶
添加词典文件到当前scws 对象 参数fpath 词典的文件路径,词典格式是XDB或XT 格式。 参数mode有3种值,分别为预定义的: SCWS_XDICT_TXT 表示要读取的词典文件是文本格式,可以和后2项结合用 SCWS_XDICT_XDB 表示直接读取 xdb 文件 SCWS_XDICT_MEM 表示将 xdb 文件全部加载到内存中,以 XTree 结构存放,可用异或结合另外2个使用。 具体用哪种方式需要根据自己的实际应用来决定。当使用本库做为守护进程时推荐使用 mem 方式, 当只是嵌入调用时应该使用 xdb 方式,将 xdb 文件加载进内存不仅占用了比较多的内存, 而且也需要一定的时间(35万条数据约需要0.3~0.5秒左右)
func (*Scws) SetCharset ¶
设定当前 scws 所使用的字符集. 参数cs 新指定的字符集.若无此调用则系统缺省使用gbk,还支持utf8,指定字符集时参数的大小写不敏感 错误若指定的字符集不存在,则会自动使用gbk 字符集替代.
func (*Scws) SetDuality ¶
设定是否将闲散文字自动以二字分词法聚合。 参数yes 如果为1 表示执行二分聚合,0 表示不处理,缺省为0
Click to show internal directories.
Click to hide internal directories.