分词模型

wordseg的Python项目详细描述


wordseg公司

DOIPyPI versionSupported Python versionsCircleCI

wordseg是一个Python分词模型包。在

目录:

安装

wordseg可通过pip获得:

pip install wordseg

要从GitHub源安装wordseg,请执行以下操作:

^{pr2}$

使用

wordseg将分词模型作为Python类实现。 实例化的模型类对象具有以下方法 (模拟scikit learn样式的API进行机器学习):

  • fit:用分段句子训练模型。在
  • predict:从未切分的句子中预测分段句子。在

实现的模型类如下:

  • RandomSegmenter: 在每个潜在的单词上随机预测切分 边界独立于给定概率。不需要培训。在
  • LongestStringMatching: 该模型通过移动来构造预测词 从左到右沿着未分段的句子和 在最大字长参数的约束下,寻找最长的匹配词。在

示例代码段:

fromwordsegimportLongestStringMatching# Initialize a model.model=LongestStringMatching(max_word_length=4)# Train the model.# `fit` takes an iterable of segmented sentences (a tuple or list of strings).model.fit([("this","is","a","sentence"),("that","is","not","a","sentence"),])# Make some predictions; `predict` gives a generator, which is materialized by list() here.list(model.predict(["thatisadog","thisisnotacat"]))# [['that', 'is', 'a', 'd', 'o', 'g'], ['this', 'is', 'not', 'a', 'c', 'a', 't']]# We can't get 'dog' and 'cat' because they aren't in the training data.

引文

李,杰克逊L。2020年。Python中的分词模型。https://doi.org/10.5281/zenodo.4077433

@software{leengrams,author={Jackson L. Lee},title={wordseg: Word segmentation models in Python},year=2020,doi={10.5281/zenodo.4077433},url={https://doi.org/10.5281/zenodo.4077433}}

许可证

麻省理工学院执照。请参阅^{}。在

变更日志

请参阅^{}。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何将cassandra中的行数据转换为与列相关的嵌套json   java如何使用jcr XPath在jcr:content/@jcr:data中搜索?   java在使用openCV进行安卓开发时如何利用手机的广角镜头   java解析扩展了接口,结束了一个潜在的无限循环   位置服务的@Override方法中存在java Android应用程序错误   java本地线程的用途和需求是什么   具有左右子访问的java节点树遍历   java验证JsonWebToken签名   JUL日志处理程序中的java日志记录   嵌入式Java读取给定时间段的串行数据。   java有没有办法从多个URL获取多个图像?   java线程通过等待intent阻止自己发送intent   java Spring MVC解析多部分内容请求   java JPA/Hibernate静态元模型属性未填充NullPointerException   java格式错误的字符(需要引号,得到I)~正在处理   java为什么PrintWriter对象抛出FileNotFoundException?   java Neo4j未正确保存标签   java IE不加载图像