zoukankan      html  css  js  c++  java
  • nltk 之 snowball 提取词干-乾颐堂

    机器学习中很重要的应用场景就是机器自动分类,而分类的关键是词干提取。所以我们要用到snowball。下面说一下snowball 提取词干的两种方法。
    两种方法:
    方法一:
    >>> from nltk import SnowballStemmer
    >>> SnowballStemmer.languages # See which languages are supported
    ('danish', 'dutch', 'english', 'finnish', 'french', 'german', 'hungarian',
     'italian', 'norwegian', 'porter', 'portuguese", 'romanian', 
     'russian', 'spanish', 'swedish')
    >>> stemmer = SnowballStemmer("german") # Choose a language
    >>> stemmer.stem(u"Autobahnen") # Stem a word
    u'autobahn'
    但是当你知道你使用的语言场景的时候可以使用下面的方法直接调用:
    方法二:
    >>> ps = nltk.stem.snowball.PortugueseStemmer()
    >>> ps.stem('celular')
    u'celul'
    >>> ps.stem('celular')
    u'celul'

    www.qytang.com/
    http://www.qytang.com/cn/list/29/
    http://www.qytang.com/cn/list/28/610.htm
    http://www.qytang.com/cn/list/28/595.htm
    http://www.qytang.com/cn/list/28/583.htm
    http://www.qytang.com/cn/list/28/582.htm
    http://www.qytang.com/cn/list/28/576.htm
    http://www.qytang.com/cn/list/28/523.htm
    http://www.qytang.com/cn/list/28/499.htm
    http://www.qytang.com/cn/list/28/488.htm
    http://www.qytang.com/cn/list/28/466.htm
    http://www.qytang.com/cn/list/28/463.htm
    http://www.qytang.com/cn/list/28/458.htm
    http://www.qytang.com/cn/list/28/455.htm
    http://www.qytang.com/cn/list/28/447.htm

  • 相关阅读:
    php学习----文件系统
    zabbix添加mysql自定义监控项
    mysql主从库不同步问题
    zabbix分区
    CentOs7.3 安装 MySQL 5.7.21 二进制版本及主从配置
    MySQL数据备份之mysqldump使用
    mysql 占用大量写I/O
    zabbix添加企业微信发送
    Centos7 更新软件及删除多余内核
    zabbix监控vCenter报错
  • 原文地址:https://www.cnblogs.com/qytang/p/5580934.html
Copyright © 2011-2022 走看看