Skip to content

ontModel 说明文档

Junchao Wu edited this page May 16, 2022 · 3 revisions

正向最长匹配分词

  • f_seg

正向最长匹配分词

>>> import qcnlp as qc
>>> text = "禁烟令人烦恼"
>>> f_list = qc.f_seg(text)
>>> print(f_list)

# ['禁烟令', '人', '烦恼']

逆向最长匹配分词

  • b_seg

逆向最长匹配分词

>>> import qcnlp as qc
>>> text = "禁烟令人烦恼"
>>> f_list = qc.b_seg(text)
>>> print(f_list)

# ['禁烟', '令人', '烦恼']

双向最长匹配分词

  • l_seg

双向最长匹配分词

>>> import qcnlp as qc
>>> text = "禁烟令人烦恼"
>>> f_list = qc.l_seg(text)
>>> print(f_list)

# ['禁烟', '令人', '烦恼']

文本句子切分

  • sentence_seg

文本句子切分,将文本切分为若干句子,提供了coarsefine粗细两种句子切分粒度, coarse 指的是按句号级别切分,fine 指按所有标点符合切分,默认按照粗粒度进行切分

>>> import qcnlp as qc
>>>text = "QCNLP,是一个小巧的NLP工具吧?是吧。"
>>>c_list = qc.sentence_seg(text,'coarse')
>>>f_list = qc.sentence_seg(text,'fine')
>>>print(c_list)
>>>print(f_list)

# ['QCNLP,是一个小巧的NLP工具吧?', '是吧。']
# ['QCNLP,', '是一个小巧的NLP工具吧?', '是吧。']
Clone this wiki locally